From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Michal Nazarewicz Newsgroups: gmane.emacs.bugs Subject: bug#19338: [PATCHv2 2/2] eldoc: convert `eldoc-documentation-function' into a defcustom Date: Thu, 11 Dec 2014 17:02:32 +0100 Message-ID: <1418313752-13536-2-git-send-email-mpn@google.com> References: <1418313752-13536-1-git-send-email-mpn@google.com> NNTP-Posting-Host: plane.gmane.org X-Trace: ger.gmane.org 1418313809 9223 80.91.229.3 (11 Dec 2014 16:03:29 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 11 Dec 2014 16:03:29 +0000 (UTC) Cc: 19338@debbugs.gnu.org To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Dec 11 17:03:22 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 1Xz6D2-00070s-Sy for geb-bug-gnu-emacs@m.gmane.org; Thu, 11 Dec 2014 17:03:21 +0100 Original-Received: from localhost ([::1]:52241 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xz6D2-00032x-E1 for geb-bug-gnu-emacs@m.gmane.org; Thu, 11 Dec 2014 11:03:20 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:59026) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xz6Cq-00030H-BL for bug-gnu-emacs@gnu.org; Thu, 11 Dec 2014 11:03:17 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Xz6Ck-0002Tq-Rr for bug-gnu-emacs@gnu.org; Thu, 11 Dec 2014 11:03:08 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:33547) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xz6Ck-0002TD-NN for bug-gnu-emacs@gnu.org; Thu, 11 Dec 2014 11:03:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1Xz6Ck-0007B1-HS for bug-gnu-emacs@gnu.org; Thu, 11 Dec 2014 11:03:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Michal Nazarewicz Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 11 Dec 2014 16:03:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 19338 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 19338-submit@debbugs.gnu.org id=B19338.141831377027560 (code B ref 19338); Thu, 11 Dec 2014 16:03:02 +0000 Original-Received: (at 19338) by debbugs.gnu.org; 11 Dec 2014 16:02:50 +0000 Original-Received: from localhost ([127.0.0.1]:42912 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Xz6CX-0007AP-W0 for submit@debbugs.gnu.org; Thu, 11 Dec 2014 11:02:50 -0500 Original-Received: from mail-wi0-f182.google.com ([209.85.212.182]:40919) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Xz6CS-00079z-SQ for 19338@debbugs.gnu.org; Thu, 11 Dec 2014 11:02:45 -0500 Original-Received: by mail-wi0-f182.google.com with SMTP id h11so9137538wiw.9 for <19338@debbugs.gnu.org>; Thu, 11 Dec 2014 08:02:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=fy0XRibtkWBbqCfMRm4tkgd110XT0l+yBn/ipNXYvwo=; b=nn2bFAE3YT2uT8UTrpwUa3BRf38CIguyu+7NfwBMPsTzDN4WEX5/afewi+SEliQ6sV bVO448hLPO7oG4E0VdCM1M53MJichCtpoteUGZO9uQOXgFeT3e7+6qN37jKyll/E1S/+ TtJOEV5zxSnj9K+Nc7q6FLH+ELLhuluL+cUfXFW7RXWurXRO0+hkuzkUWPfPBm3ZU4lk C86Qfc0lh5KE+DZ4RKUVmLci1R8YWVs6PVQ+Mm9V61aoPf3lMMNlCPmu6DGDba+ZkIQi oVlYVa2UL7HPx5yFY4Rv5A1Qjr2PoyP/TAcuA2LILVxDRNJ9sC9YISNfPnfAqe0Vkxec r+GA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=fy0XRibtkWBbqCfMRm4tkgd110XT0l+yBn/ipNXYvwo=; b=FlJEpjTlw5DcbI1IAhiWgb+JTE702g7pbwNWADQq5i7YnSfL+4zoCLFAVXiltN8X+n mFguIp3YD3iKe6jL+H+bcODJfJ+6iX1b6nXfvJ6ZWLBwqjDF9sFBN8IcWJLHqpQwBqFy GRThnegIsp4BAPO+9lZ25sjIIltbekywb5nIbRltwcC/ks1DB8pZsa2uBJ4KRau5LLAM bUFAQdNT09MDLfnqeh2xpLZp4hS5MBOldpo9LGJ21+HkrIgRP3tMyCAvSRiez4O2rZ5t 7lKnWXM0nxVmbhC/ASOAUJV8T1JRbrFkqKiD3KYvIZweMjdSnj2rApgSaKv3c85y8d7N 4v5Q== X-Gm-Message-State: ALoCoQkNEiFDH32Sc8gwyPD/XsSYo3uJRmOI1/WRBw4UT+ErzkqR2QxxxJbibK/T3vDY3AlPUSuB X-Received: by 10.180.73.143 with SMTP id l15mr17182001wiv.24.1418313758941; Thu, 11 Dec 2014 08:02:38 -0800 (PST) Original-Received: from mpn-glaptop.corp.google.com ([2620:0:105f:310:6593:e074:890e:2cc7]) by mx.google.com with ESMTPSA id h14sm2846092wic.8.2014.12.11.08.02.37 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 11 Dec 2014 08:02:38 -0800 (PST) X-Mailer: git-send-email 2.2.0.rc0.207.ga3a616c In-Reply-To: <1418313752-13536-1-git-send-email-mpn@google.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:97203 Archived-At: From: Michal Nazarewicz * lisp/emacs-lisp/eldoc.el (eldoc-documentation-function): Change from defvar to defcustom with `describe-char-eldoc' function as one of the suggested values. Describe how major modes should use `add-function' to alter value of the defcustom. * lisp/hexl.el (hexl-mode): Set `eldoc-documentation-function' using `add-function' so the default value is always used. * lisp/ielm.el (inferior-emacs-lisp-mode): Set `eldoc-documentation-function' using `add-function' so the default value is always used. * lisp/progmodes/cfengine.el (cfengine3-mode): Set `eldoc-documentation-function' using `add-function' so the default value is always used. * lisp/progmodes/elisp-mode (emacs-lisp-mode): Set `eldoc-documentation-function' using `add-function' so the default value is always used. * lisp/progmodes/octave.el (octave-mode): Set `eldoc-documentation-function' using `add-function' so the default value is always used. * lisp/progmodes/python.el (python-mode): Set `eldoc-documentation-function' using `add-function' so the default value is always used. * lisp/simple.el (read--expression): Set `eldoc-documentation-function' using `add-function' so the default value is always used. --- lisp/emacs-lisp/eldoc.el | 15 ++++++++++++--- lisp/hexl.el | 4 ++-- lisp/ielm.el | 6 +++--- lisp/progmodes/cfengine.el | 3 ++- lisp/progmodes/elisp-mode.el | 4 ++-- lisp/progmodes/octave.el | 3 ++- lisp/progmodes/python.el | 4 ++-- lisp/simple.el | 4 ++-- 8 files changed, 27 insertions(+), 16 deletions(-) diff --git a/lisp/emacs-lisp/eldoc.el b/lisp/emacs-lisp/eldoc.el index 2ee3d23..2360954 100644 --- a/lisp/emacs-lisp/eldoc.el +++ b/lisp/emacs-lisp/eldoc.el @@ -323,8 +323,8 @@ Otherwise work like `message'." ;;;###autoload -(defvar eldoc-documentation-function #'ignore - "Function to call to return doc string. +(defcustom eldoc-documentation-function #'ignore + "Function to call to return doc string for ElDoc mode. The function of no args should return a one-line string for displaying doc about a function etc. appropriate to the context around point. It should return nil if there's no doc appropriate for the context. @@ -336,7 +336,16 @@ the variables `eldoc-argument-case' and `eldoc-echo-area-use-multiline-p', and the face `eldoc-highlight-function-argument', if they are to have any effect. -This variable is expected to be set buffer-locally by modes that support ElDoc.") +Major modes should modify this variable using `add-function', for example: + (add-function :before-until (local 'eldoc-documentation-function) + #'foo-mode-eldoc-function) +so that the global documentation function (i.e. the default value of the +variable) is taken into account if the major mode specific function does not +return any documentation." + :type '(radio (function-item describe-char-eldoc) + function + (const :tag "No documentation function" #'ignore)) + :group 'eldoc) (defun eldoc-print-current-symbol-info () ;; This is run from post-command-hook or some idle timer thing, diff --git a/lisp/hexl.el b/lisp/hexl.el index 5c23f49..e1b1f98 100644 --- a/lisp/hexl.el +++ b/lisp/hexl.el @@ -394,8 +394,8 @@ You can use \\[hexl-find-file] to visit a file in Hexl mode. (add-hook 'change-major-mode-hook 'hexl-maybe-dehexlify-buffer nil t) ;; Set a callback function for eldoc. - (hexl-mode--setq-local 'eldoc-documentation-function - #'hexl-print-current-point-info) + (add-function :before-until (local 'eldoc-documentation-function) + #'hexl-print-current-point-info) (eldoc-add-command-completions "hexl-") (eldoc-remove-command "hexl-save-buffer" "hexl-current-address") diff --git a/lisp/ielm.el b/lisp/ielm.el index 37e66cc..f776f13 100644 --- a/lisp/ielm.el +++ b/lisp/ielm.el @@ -380,7 +380,7 @@ nonempty, then flushes the buffer." (*3 ***) (active-process (ielm-process)) (old-standard-output standard-output) - new-standard-output + new-standard-output ielm-temp-buffer) (set-match-data ielm-match-data) (save-excursion @@ -542,8 +542,8 @@ Customized bindings may be defined in `ielm-map', which currently contains: (set (make-local-variable 'completion-at-point-functions) '(comint-replace-by-expanded-history ielm-complete-filename elisp-completion-at-point)) - (setq-local eldoc-documentation-function - #'elisp-eldoc-documentation-function) + (add-function :before-until (local 'eldoc-documentation-function) + #'elisp-eldoc-documentation-function) (set (make-local-variable 'ielm-prompt-internal) ielm-prompt) (set (make-local-variable 'comint-prompt-read-only) ielm-prompt-read-only) (setq comint-get-old-input 'ielm-get-old-input) diff --git a/lisp/progmodes/cfengine.el b/lisp/progmodes/cfengine.el index 53d5be9..42de44e 100644 --- a/lisp/progmodes/cfengine.el +++ b/lisp/progmodes/cfengine.el @@ -1350,7 +1350,8 @@ to the action header." (when buffer-file-name (shell-quote-argument buffer-file-name))))) - (setq-local eldoc-documentation-function #'cfengine3-documentation-function) + (add-function :before-until (local 'eldoc-documentation-function) + #'cfengine3-documentation-function) (add-hook 'completion-at-point-functions #'cfengine3-completion-function nil t) diff --git a/lisp/progmodes/elisp-mode.el b/lisp/progmodes/elisp-mode.el index ba70f90..3094dec 100644 --- a/lisp/progmodes/elisp-mode.el +++ b/lisp/progmodes/elisp-mode.el @@ -229,8 +229,8 @@ Blank lines separate paragraphs. Semicolons start comments. :group 'lisp (lisp-mode-variables nil nil 'elisp) (setq imenu-case-fold-search nil) - (setq-local eldoc-documentation-function - #'elisp-eldoc-documentation-function) + (add-function :before-until (local 'eldoc-documentation-function) + #'elisp-eldoc-documentation-function) (add-hook 'completion-at-point-functions #'elisp-completion-at-point nil 'local)) diff --git a/lisp/progmodes/octave.el b/lisp/progmodes/octave.el index 7d96363..90b1e44 100644 --- a/lisp/progmodes/octave.el +++ b/lisp/progmodes/octave.el @@ -601,7 +601,8 @@ Key bindings: (add-hook 'before-save-hook 'octave-sync-function-file-names nil t) (setq-local beginning-of-defun-function 'octave-beginning-of-defun) (and octave-font-lock-texinfo-comment (octave-font-lock-texinfo-comment)) - (setq-local eldoc-documentation-function 'octave-eldoc-function) + (add-function :before-until (local 'eldoc-documentation-function) + 'octave-eldoc-function) (easy-menu-add octave-mode-menu)) diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index 63597d5..586109a 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el @@ -4378,8 +4378,8 @@ Arguments START and END narrow the buffer region to work on." (current-column)))) (^ '(- (1+ (current-indentation)))))) - (set (make-local-variable 'eldoc-documentation-function) - #'python-eldoc-function) + (add-function :before-until (local 'eldoc-documentation-function) + #'python-eldoc-function) (add-to-list 'hs-special-modes-alist `(python-mode "^\\s-*\\(?:def\\|class\\)\\>" nil "#" diff --git a/lisp/simple.el b/lisp/simple.el index 9f44798..806581b 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -1407,8 +1407,8 @@ display the result of expression evaluation." (minibuffer-with-setup-hook (lambda () ;; FIXME: call emacs-lisp-mode? - (setq-local eldoc-documentation-function - #'elisp-eldoc-documentation-function) + (add-function :before-until (local 'eldoc-documentation-function) + #'elisp-eldoc-documentation-function) (add-hook 'completion-at-point-functions #'elisp-completion-at-point nil t) (run-hooks 'eval-expression-minibuffer-setup-hook)) -- 2.2.0.rc0.207.ga3a616c