all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Thierry Volpiatto <thierry.volpiatto@gmail.com>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: 18048@debbugs.gnu.org
Subject: bug#18048: 24.3.92; [patch] eldoc improvements
Date: Mon, 21 Jul 2014 17:13:57 +0200	[thread overview]
Message-ID: <87k376spqi.fsf@gmail.com> (raw)
In-Reply-To: <87d2cy99fl.fsf@gmail.com>


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) " "))
 
 \f
 ;; 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 





  reply	other threads:[~2014-07-21 15:13 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-18  5:46 bug#18048: 24.3.92; [patch] eldoc improvements Thierry Volpiatto
2014-07-19  3:07 ` Stefan Monnier
2014-07-19  5:25   ` Thierry Volpiatto
2014-07-19  5:46   ` Thierry Volpiatto
2014-07-19  8:11   ` Thierry Volpiatto
2014-07-19 17:01     ` Stefan Monnier
2014-07-21  7:24       ` Thierry Volpiatto
2014-08-18 19:32         ` Stefan Monnier
2014-08-19  5:39           ` Thierry Volpiatto
2014-09-04 14:50             ` Stefan Monnier
2014-07-21 12:27       ` Thierry Volpiatto
2014-07-21 15:13         ` Thierry Volpiatto [this message]
2014-07-22  6:16           ` Thierry Volpiatto

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87k376spqi.fsf@gmail.com \
    --to=thierry.volpiatto@gmail.com \
    --cc=18048@debbugs.gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.