From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Thierry Volpiatto Newsgroups: gmane.emacs.bugs Subject: bug#18048: 24.3.92; [patch] eldoc improvements Date: Mon, 21 Jul 2014 17:13:57 +0200 Message-ID: <87k376spqi.fsf@gmail.com> References: <87egxjxkxh.fsf@gmail.com> <8738dx6a0g.fsf@gmail.com> <87d2cy99fl.fsf@gmail.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1405956094 8927 80.91.229.3 (21 Jul 2014 15:21:34 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 21 Jul 2014 15:21:34 +0000 (UTC) Cc: 18048@debbugs.gnu.org To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Jul 21 17:21:26 2014 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1X9FP0-0002e9-T7 for geb-bug-gnu-emacs@m.gmane.org; Mon, 21 Jul 2014 17:21:23 +0200 Original-Received: from localhost ([::1]:34691 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X9FP0-0001ZV-8v for geb-bug-gnu-emacs@m.gmane.org; Mon, 21 Jul 2014 11:21:22 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:59224) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X9FOo-0001YF-MF for bug-gnu-emacs@gnu.org; Mon, 21 Jul 2014 11:21:19 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X9FOg-0005Tg-56 for bug-gnu-emacs@gnu.org; Mon, 21 Jul 2014 11:21:10 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:38252) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X9FOg-0005Ta-2m for bug-gnu-emacs@gnu.org; Mon, 21 Jul 2014 11:21:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1X9FOf-0004gt-Ls for bug-gnu-emacs@gnu.org; Mon, 21 Jul 2014 11:21:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Thierry Volpiatto Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 21 Jul 2014 15:21:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 18048 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 18048-submit@debbugs.gnu.org id=B18048.140595604917995 (code B ref 18048); Mon, 21 Jul 2014 15:21:01 +0000 Original-Received: (at 18048) by debbugs.gnu.org; 21 Jul 2014 15:20:49 +0000 Original-Received: from localhost ([127.0.0.1]:33518 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1X9FOO-0004g1-Ch for submit@debbugs.gnu.org; Mon, 21 Jul 2014 11:20:49 -0400 Original-Received: from mail-wg0-f51.google.com ([74.125.82.51]:61510) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1X9FOG-0004fd-Tk for 18048@debbugs.gnu.org; Mon, 21 Jul 2014 11:20:41 -0400 Original-Received: by mail-wg0-f51.google.com with SMTP id b13so6539855wgh.34 for <18048@debbugs.gnu.org>; Mon, 21 Jul 2014 08:20:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=references:from:to:cc:subject:date:in-reply-to:message-id :mime-version:content-type; bh=n95jjRmSA4nX0uamhsOtJIBHbMzyjYYpOUPGTERjQEk=; b=K6RFAiqWzqYnOViefcmfk2UVU5FYMpTwh6/dDT/vMYM3sCqlRAtGg0EHFzLrsWzq+N +bh6iJ2RlZ0DE1s29Kayi0Vi3gfc+itmIIwVwku4IXvQ1Wh17Ln4bUBduqpchhT1rWMt sIyXmFK4azR0g40xx58IRzaoL1W51N1HJEhSlTt47DNDnSmIzyzsfNxkAO3doK+unyI0 BxBxRsK4HRt/utggS3DLY7qZ9JGPMD9LiPHpDY4tvgbh1RpgidSgaqKA9hO0ckUx3Cqr yeq1eEdeyH1sbvkLq3tMlt4BvFdrwK5o1cCRNQD4MTLmEuvUeVDDKpi18DgZAgPEejQg MtEA== X-Received: by 10.195.13.79 with SMTP id ew15mr22889098wjd.19.1405956028720; Mon, 21 Jul 2014 08:20:28 -0700 (PDT) Original-Received: from dell-14z ([37.163.142.75]) by mx.google.com with ESMTPSA id de6sm38348562wjc.16.2014.07.21.08.20.25 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Mon, 21 Jul 2014 08:20:27 -0700 (PDT) In-reply-to: <87d2cy99fl.fsf@gmail.com> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:91728 Archived-At: 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