Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lisp: introduce new kinds: variable, macro, and consant #2425

Merged
merged 6 commits into from
Feb 19, 2020

Conversation

masatake
Copy link
Member

Close #2423.

@coveralls
Copy link

coveralls commented Feb 14, 2020

Coverage Status

Coverage increased (+0.05%) to 86.61% when pulling c638123 on masatake:emacs-lisp into 926fe23 on universal-ctags:master.

@masatake
Copy link
Member Author

masatake commented Feb 14, 2020

TODO

  • adding a test case for QUOTE, and
  • adding a test case for namespace (package?) of common lisp.

@codecov-io
Copy link

codecov-io commented Feb 14, 2020

Codecov Report

Merging #2425 into master will increase coverage by 0.05%.
The diff coverage is 94.78%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2425      +/-   ##
==========================================
+ Coverage   86.45%   86.51%   +0.05%     
==========================================
  Files         176      176              
  Lines       36014    36111      +97     
==========================================
+ Hits        31136    31240     +104     
+ Misses       4878     4871       -7
Impacted Files Coverage Δ
parsers/lisp.c 89.33% <94.78%> (+32.72%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 926fe23...c638123. Read the comment docs.

@AmaiKinono
Copy link
Member

This is amazing. Seems most things in elisp are covered. Here are some more that may be reasonable to add:

  • define-global-minor-mode: This is an alias of define-globalized-minor-mode.
  • define-inline: Inline function.

and things offerd by cl-lib:

  • cl-defun: Function. An alias of it is defun*.
  • cl-defgeneric and cl-defmethod: Define generic function and new method for a generic function.
  • cl-defsubst: Inline function. An alias is defsubst*.
  • cl-defmacro: Macro. An alias is defmacro*.
  • cl-define-compiler-macro: Macro.

You can eval this in Emacs to get a list of callable symbols start with def or cl-def, with their documentation:

(let ((collection nil))
  (dolist (sym
           (append
            (all-completions "def" obarray)
            (all-completions "cl-def" obarray)))
    (when (fboundp (intern sym))
      (push sym collection)))
  (dolist (elt collection)
    (insert "\n")
    (insert (format "%-35s" elt))
    (when (documentation (intern elt))
      (insert (car (split-string
                    (documentation (intern elt)) "\n"))))))

@masatake
Copy link
Member Author

Thank you.

In this cycle, I will not work on cl- prefix. The original lisp parser heavily replies token starting from "def".

I will add following items to this request as you suggested:

  • define-global-minor-mode
  • define-inline
  • defun*
  • defsubst*
  • defmacro*

The rest of them will be supported in planed Sexp meta parser.

@masatake
Copy link
Member Author

Private memo:

--langdef=EmacsLisp{base=Sexp}
--map-EmacsLisp=.el
--kinddef-EmacsLisp=f,function,functions
--kinddef-EmacsLisp=a,advise,advises
--fielddef-EmacsLisp=function,fuction the advice attaches to
# (defun foo (a &rest r)
--Sexp-EmacsLisp=defun/car/f/{iftype=symbol}{field=signature:cadr}
# (defun* bar (arg) ...
--Sexp-EmacsLisp=defun*/car/f{iftype=symbol}{field=signature:cadr}
# (defadvice foo (class name ...)
--Sexp-EmacsLisp=defadvise/cadadr/a/{iftype=symbol}{field=function:car}

--langdef-Scheme{base=Sexp}
--map-Scheme=.scm
--kinddef-Scheme=v,variable,variables
--kinddef-Scheme=p,proc,procedure
# (define (foo args) ...)
--Sexp-Scheme=define/caar/p/{iftype=symbol}{field=signature:cdar}
# (define bar val)
--Sexp-Scheme=define/car/v/{iftype=symbol}

masatake added a commit to masatake/ctags that referenced this pull request Feb 15, 2020
The new parser can support more emacs specific kinds like defcustom.

The keywords, define-global-minor-mode, define-inline, defun*,
defsubst*, and defmacro* are suggsted by @AmaiKinono.

More keyword candidates can be listed with following elisp
(takne from the comment submitted by @AmaiKinono in universal-ctags#2425)

(let ((collection nil))
  (dolist (sym
           (append
            (all-completions "def" obarray)
            (all-completions "cl-def" obarray)))
    (when (fboundp (intern sym))
      (push sym collection)))
  (dolist (elt collection)
    (insert "\n")
    (insert (format "%-35s" elt))
    (when (documentation (intern elt))
      (insert (car (split-string
                    (documentation (intern elt)) "\n"))))))

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
Close universal-ctags#2423.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
The parser is line oritend. So f in

    (defun
     f () 1)

is not captured.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
The new parser can support more emacs specific kinds like defcustom.

The keywords, define-global-minor-mode, define-inline, defun*,
defsubst*, and defmacro* are suggsted by @AmaiKinono.

More keyword candidates can be listed with following elisp
(takne from the comment submitted by @AmaiKinono in universal-ctags#2425)

(let ((collection nil))
  (dolist (sym
           (append
            (all-completions "def" obarray)
            (all-completions "cl-def" obarray)))
    (when (fboundp (intern sym))
      (push sym collection)))
  (dolist (elt collection)
    (insert "\n")
    (insert (format "%-35s" elt))
    (when (documentation (intern elt))
      (insert (car (split-string
                    (documentation (intern elt)) "\n"))))))

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
@masatake
Copy link
Member Author

Added a test case including quote.
The changes are for emacs-lisp. So I don't touch test cases for Common Lisp here.

@masatake masatake merged commit 493437d into universal-ctags:master Feb 19, 2020
masatake added a commit to masatake/ctags that referenced this pull request Mar 6, 2020
Close universal-ctags#2425.

TODO: This change doesn't handle anonymous functions like

```
auto lg5 = [](X<int,int> x,X<long,long>) -> X<double,double> { return X<double,double>(); };
```

well.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
masatake added a commit to masatake/ctags that referenced this pull request Mar 6, 2020
Close universal-ctags#2425.

TODO: This change doesn't handle anonymous functions like

```
auto lg5 = [](X<int,int> x,X<long,long>) -> X<double,double> { return X<double,double>(); };
```

well.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Lisp: ctags seems to think all symbols are functions
4 participants