]> code.delx.au - gnu-emacs/blobdiff - lisp/emacs-lisp/eldoc.el
* emacs-lisp/package.el (package-dir-info): New function.
[gnu-emacs] / lisp / emacs-lisp / eldoc.el
index 7245989c4b02b9f817dc84262a06a85dbc822f2c..0c74f3fedc01c63f7a89109daf745ba79296d3cb 100644 (file)
@@ -1,6 +1,6 @@
 ;;; eldoc.el --- Show function arglist or variable docstring in echo area  -*- lexical-binding:t; -*-
 
-;; Copyright (C) 1996-2014 Free Software Foundation, Inc.
+;; Copyright (C) 1996-2015 Free Software Foundation, Inc.
 
 ;; Author: Noah Friedman <friedman@splode.com>
 ;; Maintainer: friedman@splode.com
@@ -47,9 +47,6 @@
 
 ;;; Code:
 
-(require 'help-fns)                   ;For fundoc-usage handling functions.
-(require 'cl-lib)
-
 (defgroup eldoc nil
   "Show function arglist or variable docstring in echo area."
   :group 'lisp
@@ -82,8 +79,8 @@ This has two preferred values: `upcase' or `downcase'.
 Actually, any name of a function which takes a string as an argument and
 returns another string is acceptable.
 
-Note that if `eldoc-documentation-function' is non-nil, this variable
-has no effect, unless the function handles it explicitly."
+Note that this variable has no effect, unless
+`eldoc-documentation-function' handles it explicitly."
   :type '(radio (function-item upcase)
                (function-item downcase)
                 function)
@@ -105,8 +102,8 @@ If value is nil, messages are always truncated to fit in a single line of
 display in the echo area.  Function or variable symbol name may be
 truncated to make more of the arglist or documentation string visible.
 
-Note that if `eldoc-documentation-function' is non-nil, this variable
-has no effect, unless the function handles it explicitly."
+Note that this variable has no effect, unless
+`eldoc-documentation-function' handles it explicitly."
   :type '(radio (const :tag "Always" t)
                 (const :tag "Never" nil)
                 (const :tag "Yes, but truncate symbol names if it will\
@@ -129,7 +126,8 @@ choose to increase the number of buckets, you must do so before loading
 this file since the obarray is initialized at load time.
 Remember to keep it a prime number to improve hash performance.")
 
-(defconst eldoc-message-commands
+(defvar eldoc-message-commands
+  ;; Don't define as `defconst' since it would then go to (read-only) purespace.
   (make-vector eldoc-message-commands-table-size 0)
   "Commands after which it is appropriate to print in the echo area.
 ElDoc does not try to print function arglists, etc., after just any command,
@@ -140,12 +138,14 @@ This variable contains an obarray of symbols; do not manipulate it
 directly.  Instead, use `eldoc-add-command' and `eldoc-remove-command'.")
 
 ;; Not a constant.
-(defconst eldoc-last-data (make-vector 3 nil)
+(defvar eldoc-last-data (make-vector 3 nil)
+  ;; Don't define as `defconst' since it would then go to (read-only) purespace.
   "Bookkeeping; elements are as follows:
   0 - contains the last symbol read from the buffer.
   1 - contains the string last displayed in the echo area for variables,
       or argument string for functions.
-  2 - 'function if function args, 'variable if variable documentation.")
+  2 - `function' if function args, `variable' if variable documentation.")
+(make-obsolete-variable 'eldoc-last-data "use your own instead" "25.1")
 
 (defvar eldoc-last-message nil)
 
@@ -186,7 +186,7 @@ expression point is on."
   :group 'eldoc :lighter eldoc-minor-mode-string
   (setq eldoc-last-message nil)
   (cond
-   ((not eldoc-documentation-function)
+   ((memq eldoc-documentation-function '(nil ignore))
     (message "There is no ElDoc support in this buffer")
     (setq eldoc-mode nil))
    (eldoc-mode
@@ -203,14 +203,13 @@ expression point is on."
 (define-minor-mode global-eldoc-mode
   "Enable `eldoc-mode' in all buffers where it's applicable."
   :group 'eldoc :global t
+  :initialize 'custom-initialize-delay
+  :init-value t
   (setq eldoc-last-message nil)
   (if global-eldoc-mode
       (progn
-       (when eldoc-print-after-edit
-         (setq-local eldoc-message-commands (eldoc-edit-message-commands)))
        (add-hook 'post-command-hook #'eldoc-schedule-timer)
        (add-hook 'pre-command-hook #'eldoc-pre-command-refresh-echo-area))
-    (kill-local-variable 'eldoc-message-commands)
     (remove-hook 'post-command-hook #'eldoc-schedule-timer)
     (remove-hook 'pre-command-hook #'eldoc-pre-command-refresh-echo-area)))
 
@@ -226,7 +225,9 @@ expression point is on."
             eldoc-idle-delay t
             (lambda ()
                (when (or eldoc-mode
-                         (and global-eldoc-mode eldoc-documentation-function))
+                         (and global-eldoc-mode
+                              (not (memq eldoc-documentation-function
+                                         '(nil ignore)))))
                  (eldoc-print-current-symbol-info))))))
 
   ;; If user has changed the idle delay, update the timer.
@@ -322,7 +323,7 @@ Otherwise work like `message'."
 
 \f
 ;;;###autoload
-(defvar eldoc-documentation-function nil
+(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.