[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#18048: 24.3.92; [patch] eldoc improvements
From: |
Thierry Volpiatto |
Subject: |
bug#18048: 24.3.92; [patch] eldoc improvements |
Date: |
Mon, 21 Jul 2014 17:13:57 +0200 |
Here all changes done on eldoc.el:
1) Fix highlighting args in setq or similar &rest args.
2) Fix highlighting cl keyword args with &key.
3) Don't upcase &key and &allow-other-keys.
Changes from master to working directory
1 file changed, 36 insertions(+), 9 deletions(-)
lisp/emacs-lisp/eldoc.el | 45 ++++++++++++++++++++++++++++++++++++---------
Modified lisp/emacs-lisp/eldoc.el
diff --git a/lisp/emacs-lisp/eldoc.el b/lisp/emacs-lisp/eldoc.el
index 7102b55..9959f57 100644
--- a/lisp/emacs-lisp/eldoc.el
+++ b/lisp/emacs-lisp/eldoc.el
@@ -388,6 +388,27 @@ In the absence of INDEX, just call
`eldoc-docstring-format-sym-doc'."
;; (defun NAME ARGLIST [DOCSTRING] BODY...) case?
;; The problem is there is no robust way to determine if
;; the current argument is indeed a docstring.
+ (when (string-match "&key" args)
+ (let* (case-fold-search
+ (cur-w (current-word))
+ (args-lst (mapcar (lambda (x)
+ (replace-regexp-in-string
+ "\\`[(]\\|[)]\\'" "" x))
+ (split-string args)))
+ (args-lst-ak (member "&key" args-lst))
+ (limit (save-excursion
+ (when (re-search-backward (symbol-name sym) nil t)
+ (match-end 0))))
+ (cur-a (if (string-match ":\\([^ ()]*\\)" cur-w)
+ (substring cur-w 1)
+ (save-excursion
+ (if (re-search-backward ":\\([^ ()\n]*\\)" limit t)
+ (match-string 1)
+ cur-w)))))
+ (when (member (upcase cur-a) args-lst-ak)
+ (setq index nil
+ start (string-match (upcase cur-a) args)
+ end (match-end 0)))))
(while (and index (>= index 1))
(if (string-match "[^ ()]+" args end)
(progn
@@ -398,8 +419,11 @@ In the absence of INDEX, just call
`eldoc-docstring-format-sym-doc'."
;; All the rest arguments are the same.
(setq index 1))
((string= argument "&optional"))
- ((string-match-p "\\.\\.\\.$" argument)
- (setq index 0))
+ ((string= argument "&allow-other-keys"))
+ ((or (string-match-p "\\.\\.\\.$" argument)
+ (and (string-match-p "\\.\\.\\.)?$" args)
+ (> index 1) (oddp index)))
+ (setq index 0))
(t
(setq index (1- index))))))
(setq end (length args)
@@ -548,13 +572,16 @@ ARGLIST is either a string, or a list of strings or
symbols."
(format "(%s)" arglist)))
(defun eldoc-function-argstring-format (argstring)
- "Apply `eldoc-argument-case' to each word in ARGSTRING.
-The words \"&rest\", \"&optional\" are returned unchanged."
- (mapconcat (lambda (s)
- (if (string-match-p "\\`(?&\\(?:optional\\|rest\\))?\\'" s)
- s
- (funcall eldoc-argument-case s)))
- (split-string argstring) " "))
+ "Apply `eldoc-argument-case' to each word in ARGSTRING.
+The words \"&rest\", \"&optional\", \"&key\" and \"&allow-other-keys\"
+are returned unchanged."
+ (mapconcat
+ (lambda (s)
+ (if (string-match-p
+ "\\`(?&\\(?:optional\\|rest\\|key\\|allow-other-keys\\))?\\'" s)
+ s
+ (funcall eldoc-argument-case s)))
+ (split-string argstring) " "))
;; When point is in a sexp, the function args are not reprinted in the echo
--
Thierry
Get my Gnupg key:
gpg --keyserver pgp.mit.edu --recv-keys 59F29997