From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Mark Oteiza Newsgroups: gmane.emacs.devel Subject: Re: [PATCH] RFC: eldoc-documentation-functions hook Date: Sun, 12 Jun 2016 14:24:53 -0400 Message-ID: <20160612182453.GA12034@holos.localdomain> References: <20160612061229.GA6463@holos.localdomain> <838tyahoim.fsf@gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1465755924 17738 80.91.229.3 (12 Jun 2016 18:25:24 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 12 Jun 2016 18:25:24 +0000 (UTC) Cc: emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Jun 12 20:25:16 2016 Return-path: Envelope-to: ged-emacs-devel@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 1bCA4K-0005CN-2o for ged-emacs-devel@m.gmane.org; Sun, 12 Jun 2016 20:25:08 +0200 Original-Received: from localhost ([::1]:52275 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bCA4J-00022g-2k for ged-emacs-devel@m.gmane.org; Sun, 12 Jun 2016 14:25:07 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:48239) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bCA4C-00021z-SZ for emacs-devel@gnu.org; Sun, 12 Jun 2016 14:25:02 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bCA48-00039a-Ha for emacs-devel@gnu.org; Sun, 12 Jun 2016 14:24:59 -0400 Original-Received: from mail-qg0-x233.google.com ([2607:f8b0:400d:c04::233]:33075) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bCA48-00039P-An for emacs-devel@gnu.org; Sun, 12 Jun 2016 14:24:56 -0400 Original-Received: by mail-qg0-x233.google.com with SMTP id l44so57418752qgd.0 for ; Sun, 12 Jun 2016 11:24:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=udel-edu.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=ubHNmzs4rVWvYWs3KX3qTKc7FlEdABJe2uBh7QNbHKQ=; b=ZhJrjKRDufwVLOji4ZRKH+ZjPkyKsZF6s7kfVVfNC6gRKljvy2vEy3sI7+syVSzOt6 JdUTbQRObmL19/+xqICKr1+fg+PelSSMvDKfMU4QDV2LHheiqZ34lisJlD4DCbJnuPBq iCpt7hxwOvEqKASIZZqtAelV4oMkWeJAghRdUwQBEop3fVCHPwf9NjGEg5E1jNL56iKp 6F2LcREsG4zHLe40T4nCsipBk1OAo6kHG24gVx/ae/A+58t/wo5DUhaC2j4qm/WAYrah 54nHWwsBgHXpr9RAl08qx+CemxkoK0p2joDxC4ZKxGdNM8d+U1hEZ+VSK6tVCa9HENH+ pQ5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=ubHNmzs4rVWvYWs3KX3qTKc7FlEdABJe2uBh7QNbHKQ=; b=jkuhT7Qqcil/Q1vRFzHXX40srHqd06sWXz6mPMERUWbPb48cZPKX2CnKB0VlfMTKiz dJL4oj39+WFEVLpHbYdcTH0qDK4vpR6b/zLksFRyd0USYPjVwvrnLFmIA0JPeFH69T3Q cC1yNtUh97xLOJFk+tJ9EWF+D5+cV0vLYHljrp/NsE8vpkvfNWq+3Mof55uh+4bpgk+b WVy1anxOKhI3+ko4E5Fnzh+C3cFWcQrlI/P9EjstEy4t50rMuWNuY4Z4EACspCeU6a6F EvNlK2CR0Cp+Vazc4TUX3ciPna2m4TipM7V1n5FublmdJRrUamGuNks2F5y3rx9MTmeN JS1A== X-Gm-Message-State: ALyK8tLZ89xsQdAvdQ5XSAcJrghwDO1mKGRmiJpUDv2TsxeWRLp1TfaJUPAzTzZBNcofgD3T X-Received: by 10.140.41.164 with SMTP id z33mr743395qgz.54.1465755895372; Sun, 12 Jun 2016 11:24:55 -0700 (PDT) Original-Received: from holos.localdomain (ip68-100-200-121.dc.dc.cox.net. [68.100.200.121]) by smtp.gmail.com with ESMTPSA id 45sm4572484qtr.5.2016.06.12.11.24.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 12 Jun 2016 11:24:54 -0700 (PDT) Original-Received: by holos.localdomain (Postfix, from userid 1000) id A28F069683; Sun, 12 Jun 2016 14:24:53 -0400 (EDT) Content-Disposition: inline In-Reply-To: <838tyahoim.fsf@gnu.org> User-Agent: Mutt/1.6.1+26 (8e342d73159b) (2016-04-27) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:400d:c04::233 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:204315 Archived-At: --- On 12/06/16 at 10:09am, Eli Zaretskii wrote: > > Date: Sun, 12 Jun 2016 02:12:29 -0400 > > From: Mark Oteiza > > > > This is a draft patch changing eldoc-documentation-function into a hook > > variable, so instead of using add-function, one can instead use add-hook > > to control the behavior of eldoc. It is backwards compatible. > > Thanks. Please be sure to update the ELisp manual accordingly. Thanks, looks like there's just one place. Also added a mention in NEWS and changed the default value back to nil, since this isn't being unconditionally funcall'd anymore. In the manual, it appears that the -functions suffix is to be used for abnormal hooks; however this is a normal hook, so it would seem the name should use the -hook suffix. diff --git a/doc/lispref/modes.texi b/doc/lispref/modes.texi index 7b76e6a..b5d07da 100644 --- a/doc/lispref/modes.texi +++ b/doc/lispref/modes.texi @@ -417,7 +417,7 @@ Major Mode Conventions @item The mode can specify a local value for -@code{eldoc-documentation-function} to tell ElDoc mode how to handle +@code{eldoc-documentation-functions} to tell ElDoc mode how to handle this mode. @item diff --git a/etc/NEWS b/etc/NEWS index e2c99a1..92bf8e4 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -212,6 +212,12 @@ viewing HTML files and the like. breakpoint (e.g. with "f" and "o") by customizing the new option 'edebug-sit-on-break'. +** ElDoc + ++++ +*** 'eldoc-documentation-functions' replaces 'eldoc-documentation-function'. +This is now a hook variable; its default value is nil. + ** eww +++ diff --git a/lisp/emacs-lisp/eldoc.el b/lisp/emacs-lisp/eldoc.el index 6c2f869..812c398 100644 --- a/lisp/emacs-lisp/eldoc.el +++ b/lisp/emacs-lisp/eldoc.el @@ -43,7 +43,7 @@ ;; Major modes for other languages may use ElDoc by defining an ;; appropriate function as the buffer-local value of -;; `eldoc-documentation-function'. +;; `eldoc-documentation-functions'. ;;; Code: @@ -80,7 +80,7 @@ eldoc-argument-case returns another string is acceptable. Note that this variable has no effect, unless -`eldoc-documentation-function' handles it explicitly." +`eldoc-documentation-functions' handle it explicitly." :type '(radio (function-item upcase) (function-item downcase) function) @@ -103,7 +103,7 @@ eldoc-echo-area-use-multiline-p truncated to make more of the arglist or documentation string visible. Note that this variable has no effect, unless -`eldoc-documentation-function' handles it explicitly." +`eldoc-documentation-functions' handle it explicitly." :type '(radio (const :tag "Always" t) (const :tag "Never" nil) (const :tag "Yes, but truncate symbol names if it will\ @@ -113,8 +113,8 @@ eldoc-echo-area-use-multiline-p (defface eldoc-highlight-function-argument '((t (:inherit bold))) "Face used for the argument at point in a function's argument list. -Note that this face has no effect unless the `eldoc-documentation-function' -handles it explicitly." +Note that this face has no effect unless the `eldoc-documentation-functions' +handle it explicitly." :group 'eldoc) ;;; No user options below here. @@ -186,7 +186,7 @@ eldoc-mode :group 'eldoc :lighter eldoc-minor-mode-string (setq eldoc-last-message nil) (cond - ((memq eldoc-documentation-function '(nil ignore)) + ((not (eldoc-supported-p)) (message "There is no ElDoc support in this buffer") (setq eldoc-mode nil)) (eldoc-mode @@ -211,7 +211,7 @@ global-eldoc-mode If Global Eldoc mode is on, `eldoc-mode' will be enabled in all buffers where it's applicable. These are buffers that have modes -that have enabled eldoc support. See `eldoc-documentation-function'." +that have enabled eldoc support. See `eldoc-documentation-functions'." :group 'eldoc :global t :initialize 'custom-initialize-delay @@ -236,9 +236,7 @@ eldoc-schedule-timer eldoc-idle-delay nil (lambda () (when (or eldoc-mode - (and global-eldoc-mode - (not (memq eldoc-documentation-function - '(nil ignore))))) + (and global-eldoc-mode (eldoc-supported-p))) (eldoc-print-current-symbol-info)))))) ;; If user has changed the idle delay, update the timer. @@ -334,26 +332,29 @@ eldoc-display-message-no-interference-p ;;;###autoload -(defvar eldoc-documentation-function #'ignore - "Function to call to return doc string. -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. -Typically doc is returned if point is on a function-like name or in its -arg list. +(defvar eldoc-documentation-functions nil + "Hook to run to obtain doc string. +Each element of this variable should be a function of no args +that returns a one-line string for displaying doc about a +function etc. appropriate to the context around point. It should +return nil if there is no doc appropriate for the context. +Typically, doc is returned if point is on a function-like name or +in its arg list. The result is used as is, so the function must explicitly handle 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. -Major modes should modify this variable using `add-function', for example: - (add-function :before-until (local \\='eldoc-documentation-function) - #\\='foo-mode-eldoc-function) +Major modes should modify this variable using `add-hook', for example: + (add-hook \\='eldoc-documentation-functions #\\='foo-eldoc nil t) 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.") +(define-obsolete-variable-alias 'eldoc-documentation-function + 'eldoc-documentation-functions "25.2") + (defun eldoc-print-current-symbol-info () ;; This is run from post-command-hook or some idle timer thing, ;; so we need to be careful that errors aren't ignored. @@ -363,7 +364,19 @@ eldoc-print-current-symbol-info (when eldoc-last-message (eldoc-message nil) nil)) - (eldoc-message (funcall eldoc-documentation-function))))) + (eldoc-message + (run-hook-with-args-until-success 'eldoc-documentation-functions))))) + +(defun eldoc-supported-p () + "Return t if `eldoc-documentation-functions' has non-null elements." + (when eldoc-documentation-functions + (catch :eldoc-supported + (mapc + (lambda (fun) + (when (not (memq fun '(nil ignore))) + (throw :eldoc-supported t))) + eldoc-documentation-functions) + nil))) ;; If the entire line cannot fit in the echo area, the symbol name may be ;; truncated or eliminated entirely from the output to make room for the