summaryrefslogtreecommitdiff
path: root/lisp/emacs-lisp
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/emacs-lisp')
-rw-r--r--lisp/emacs-lisp/advice.el2
-rw-r--r--lisp/emacs-lisp/autoload.el16
-rw-r--r--lisp/emacs-lisp/cl-loaddefs.el7
-rw-r--r--lisp/emacs-lisp/cl.el2
-rw-r--r--lisp/emacs-lisp/copyright.el2
-rw-r--r--lisp/emacs-lisp/easymenu.el40
-rw-r--r--lisp/emacs-lisp/eldoc.el120
-rw-r--r--lisp/emacs-lisp/lisp-mode.el4
8 files changed, 134 insertions, 59 deletions
diff --git a/lisp/emacs-lisp/advice.el b/lisp/emacs-lisp/advice.el
index 8023bc58a53..0123124b26d 100644
--- a/lisp/emacs-lisp/advice.el
+++ b/lisp/emacs-lisp/advice.el
@@ -3759,7 +3759,7 @@ The syntax of `defadvice' is as follows:
\(defadvice FUNCTION (CLASS NAME [POSITION] [ARGLIST] FLAG...)
[DOCSTRING] [INTERACTIVE-FORM]
- BODY... )
+ BODY...)
FUNCTION ::= Name of the function to be advised.
CLASS ::= `before' | `around' | `after' | `activation' | `deactivation'.
diff --git a/lisp/emacs-lisp/autoload.el b/lisp/emacs-lisp/autoload.el
index 93ba83bb729..6495ca2a5e9 100644
--- a/lisp/emacs-lisp/autoload.el
+++ b/lisp/emacs-lisp/autoload.el
@@ -41,6 +41,7 @@
A `.el' file can set this in its local variables section to make its
autoloads go somewhere else. The autoload file is assumed to contain a
trailer starting with a FormFeed character.")
+;;;###autoload
(put 'generated-autoload-file 'safe-local-variable 'stringp)
;; This feels like it should be a defconst, but MH-E sets it to
@@ -432,7 +433,10 @@ Return non-nil iff FILE adds no autoloads to OUTFILE
;; checksum in secondary autoload files where we do
;; not need the time-stamp optimization because it is
;; already provided by the primary autoloads file.
- (md5 secondary-autoloads-file-buf nil nil 'emacs-mule)
+ (md5 secondary-autoloads-file-buf
+ ;; We'd really want to just use
+ ;; `emacs-internal' instead.
+ nil nil 'emacs-mule-unix)
(nth 5 (file-attributes relfile))))
(insert ";;; Generated autoloads from " relfile "\n"))
(insert generate-autoload-section-trailer))))
@@ -559,6 +563,7 @@ directory or directories specified."
(directory-files (expand-file-name dir)
t files-re))
dirs)))
+ (done ())
(this-time (current-time))
;; Files with no autoload cookies or whose autoloads go to other
;; files because of file-local autoload-generated-file settings.
@@ -592,10 +597,10 @@ directory or directories specified."
(push file no-autoloads)
(setq files (delete file files)))))))
((not (stringp file)))
- ((not (and (file-exists-p file)
- ;; Remove duplicates as well, just in case.
- (member file files)))
- ;; Remove the obsolete section.
+ ((or (not (file-exists-p file))
+ ;; Remove duplicates as well, just in case.
+ (member file done))
+ ;; Remove the obsolete section.
(autoload-remove-section (match-beginning 0)))
((not (time-less-p (nth 4 form)
(nth 5 (file-attributes file))))
@@ -606,6 +611,7 @@ directory or directories specified."
(if (autoload-generate-file-autoloads
file (current-buffer) buffer-file-name)
(push file no-autoloads))))
+ (push file done)
(setq files (delete file files)))))
;; Elements remaining in FILES have no existing autoload sections yet.
(dolist (file files)
diff --git a/lisp/emacs-lisp/cl-loaddefs.el b/lisp/emacs-lisp/cl-loaddefs.el
index 65cb0754446..1589e19cbb2 100644
--- a/lisp/emacs-lisp/cl-loaddefs.el
+++ b/lisp/emacs-lisp/cl-loaddefs.el
@@ -10,8 +10,7 @@
;;;;;; ceiling* floor* isqrt lcm gcd cl-progv-before cl-set-frame-visible-p
;;;;;; cl-map-overlays cl-map-intervals cl-map-keymap-recursively
;;;;;; notevery notany every some mapcon mapcan mapl maplist map
-;;;;;; cl-mapcar-many equalp coerce) "cl-extra" "cl-extra.el" (18050
-;;;;;; 46455))
+;;;;;; cl-mapcar-many equalp coerce) "cl-extra" "cl-extra.el" "47c92504dda976a632c2c10bedd4b6a4")
;;; Generated autoloads from cl-extra.el
(autoload (quote coerce) "cl-extra" "\
@@ -284,7 +283,7 @@ Not documented
;;;;;; do* do loop return-from return block etypecase typecase ecase
;;;;;; case load-time-value eval-when destructuring-bind function*
;;;;;; defmacro* defun* gentemp gensym cl-compile-time-init) "cl-macs"
-;;;;;; "cl-macs.el" (18051 52572))
+;;;;;; "cl-macs.el" "7ccc827d272482ca276937ca18a7895a")
;;; Generated autoloads from cl-macs.el
(autoload (quote cl-compile-time-init) "cl-macs" "\
@@ -746,7 +745,7 @@ Not documented
;;;;;; find nsubstitute-if-not nsubstitute-if nsubstitute substitute-if-not
;;;;;; substitute-if substitute delete-duplicates remove-duplicates
;;;;;; delete-if-not delete-if delete* remove-if-not remove-if remove*
-;;;;;; replace fill reduce) "cl-seq" "cl-seq.el" (18050 45841))
+;;;;;; replace fill reduce) "cl-seq" "cl-seq.el" "8805f76626399794931f5db36ddf855f")
;;; Generated autoloads from cl-seq.el
(autoload (quote reduce) "cl-seq" "\
diff --git a/lisp/emacs-lisp/cl.el b/lisp/emacs-lisp/cl.el
index 233df65ac91..f8b178ac07c 100644
--- a/lisp/emacs-lisp/cl.el
+++ b/lisp/emacs-lisp/cl.el
@@ -628,7 +628,7 @@ If ALIST is non-nil, the new pairs are prepended to it."
(fmakunbound 'dolist)
(fmakunbound 'dotimes)
(fmakunbound 'declare)
-(load "cl-loaddefs")
+(load "cl-loaddefs" nil 'quiet)
;; This goes here so that cl-macs can find it if it loads right now.
(provide 'cl-19) ; usage: (require 'cl-19 "cl")
diff --git a/lisp/emacs-lisp/copyright.el b/lisp/emacs-lisp/copyright.el
index d4501bd57b0..41a3144f91a 100644
--- a/lisp/emacs-lisp/copyright.el
+++ b/lisp/emacs-lisp/copyright.el
@@ -77,7 +77,7 @@ When this is `function', only ask when called non-interactively."
;; when modifying this, also modify the comment generated by autoinsert.el
-(defconst copyright-current-gpl-version "2"
+(defconst copyright-current-gpl-version "3"
"String representing the current version of the GPL or nil.")
(defvar copyright-update t)
diff --git a/lisp/emacs-lisp/easymenu.el b/lisp/emacs-lisp/easymenu.el
index d1ec5a1fe39..19df1a16a11 100644
--- a/lisp/emacs-lisp/easymenu.el
+++ b/lisp/emacs-lisp/easymenu.el
@@ -152,6 +152,21 @@ A menu item can be a list with the same format as MENU. This is a submenu."
,(if symbol `(defvar ,symbol nil ,doc))
(easy-menu-do-define (quote ,symbol) ,maps ,doc ,menu)))
+(defun easy-menu-binding (menu &optional item-name)
+ "Return a binding suitable to pass to `define-key'.
+This is expected to be bound to a mouse event."
+ ;; Under Emacs this is almost trivial, whereas under XEmacs this may
+ ;; involve defining a function that calls popup-menu.
+ (let ((props (if (symbolp menu)
+ (prog1 (get menu 'menu-prop)
+ (setq menu (symbol-function menu))))))
+ (cons 'menu-item
+ (cons (or item-name
+ (if (keymapp menu)
+ (keymap-prompt menu))
+ "")
+ (cons menu props)))))
+
;;;###autoload
(defun easy-menu-do-define (symbol maps doc menu)
;; We can't do anything that might differ between Emacs dialects in
@@ -173,15 +188,10 @@ A menu item can be a list with the same format as MENU. This is a submenu."
'identity)
(symbol-function ,symbol)))
,symbol)))))
- (mapcar (lambda (map)
- (define-key map (vector 'menu-bar (easy-menu-intern (car menu)))
- (cons 'menu-item
- (cons (car menu)
- (if (not (symbolp keymap))
- (list keymap)
- (cons (symbol-function keymap)
- (get keymap 'menu-prop)))))))
- (if (keymapp maps) (list maps) maps))))
+ (dolist (map (if (keymapp maps) (list maps) maps))
+ (define-key map
+ (vector 'menu-bar (easy-menu-intern (car menu)))
+ (easy-menu-binding keymap (car menu))))))
(defun easy-menu-filter-return (menu &optional name)
"Convert MENU to the right thing to return from a menu filter.
@@ -249,10 +259,6 @@ possibly preceded by keyword pairs as described in `easy-menu-define'."
(defvar easy-menu-button-prefix
'((radio . :radio) (toggle . :toggle)))
-(defun easy-menu-do-add-item (menu item &optional before)
- (setq item (easy-menu-convert-item item))
- (easy-menu-define-key menu (easy-menu-intern (car item)) (cdr item) before))
-
(defvar easy-menu-converted-items-table (make-hash-table :test 'equal))
(defun easy-menu-convert-item (item)
@@ -269,7 +275,7 @@ would always fail because the key is `equal' but not `eq'."
(defun easy-menu-convert-item-1 (item)
"Parse an item description and convert it to a menu keymap element.
ITEM defines an item as in `easy-menu-define'."
- (let (name command label prop remove help)
+ (let (name command label prop remove)
(cond
((stringp item) ; An item or separator.
(setq label item))
@@ -536,7 +542,8 @@ earlier by `easy-menu-define' or `easy-menu-create-menu'."
(setq item (symbol-value item))))
;; Item is a keymap, find the prompt string and use as item name.
(setq item (cons (keymap-prompt item) item)))
- (easy-menu-do-add-item map item before)))
+ (setq item (easy-menu-convert-item item))
+ (easy-menu-define-key map (easy-menu-intern (car item)) (cdr item) before)))
(defun easy-menu-item-present-p (map path name)
"In submenu of MAP with path PATH, return non-nil iff item NAME is present.
@@ -615,7 +622,8 @@ In some cases we use that to select between the local and global maps."
(catch 'found
(if (and map (symbolp map) (not (keymapp map)))
(setq map (symbol-value map)))
- (let ((maps (if map (list map) (current-active-maps))))
+ (let ((maps (if map (if (keymapp map) (list map) map)
+ (current-active-maps))))
;; Look for PATH in each map.
(unless map (push 'menu-bar path))
(dolist (name path)
diff --git a/lisp/emacs-lisp/eldoc.el b/lisp/emacs-lisp/eldoc.el
index 85b150b6ae5..37e2eb351f2 100644
--- a/lisp/emacs-lisp/eldoc.el
+++ b/lisp/emacs-lisp/eldoc.el
@@ -124,8 +124,8 @@ directly. Instead, use `eldoc-add-command' and `eldoc-remove-command'.")
(defconst eldoc-last-data (make-vector 3 nil)
"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 that
- symbol, so it can be printed again if necessary without reconsing.
+ 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.")
(defvar eldoc-last-message nil)
@@ -249,12 +249,16 @@ Emacs Lisp mode) that support Eldoc.")
(let* ((current-symbol (eldoc-current-symbol))
(current-fnsym (eldoc-fnsym-in-current-sexp))
(doc (cond
- ((eq current-symbol current-fnsym)
- (or (eldoc-get-fnsym-args-string current-fnsym)
+ ((null current-fnsym)
+ nil)
+ ((eq current-symbol (car current-fnsym))
+ (or (apply 'eldoc-get-fnsym-args-string
+ current-fnsym)
(eldoc-get-var-docstring current-symbol)))
(t
(or (eldoc-get-var-docstring current-symbol)
- (eldoc-get-fnsym-args-string current-fnsym))))))
+ (apply 'eldoc-get-fnsym-args-string
+ current-fnsym))))))
(eldoc-message doc))))
;; This is run from post-command-hook or some idle timer thing,
;; so we need to be careful that errors aren't ignored.
@@ -263,24 +267,62 @@ Emacs Lisp mode) that support Eldoc.")
;; Return a string containing the function parameter list, or 1-line
;; docstring if function is a subr and no arglist is obtainable from the
;; docstring or elsewhere.
-(defun eldoc-get-fnsym-args-string (sym)
+(defun eldoc-get-fnsym-args-string (sym argument-index)
(let ((args nil)
(doc nil))
(cond ((not (and sym (symbolp sym) (fboundp sym))))
((and (eq sym (aref eldoc-last-data 0))
(eq 'function (aref eldoc-last-data 2)))
- (setq doc (aref eldoc-last-data 1)))
+ (setq args (aref eldoc-last-data 1)))
((setq doc (help-split-fundoc (documentation sym t) sym))
(setq args (car doc))
(string-match "\\`[^ )]* ?" args)
- (setq args (concat "(" (substring args (match-end 0)))))
+ (setq args (concat "(" (substring args (match-end 0))))
+ (eldoc-last-data-store sym args 'function))
(t
(setq args (eldoc-function-argstring sym))))
- (cond (args
- (setq doc (eldoc-docstring-format-sym-doc sym args))
- (eldoc-last-data-store sym doc 'function)))
+ (when args
+ (setq doc (eldoc-highlight-function-argument sym args argument-index)))
doc))
+;; Highlight argument INDEX in ARGS list for SYM.
+(defun eldoc-highlight-function-argument (sym args index)
+ (let ((start nil)
+ (end 0)
+ (argument-face 'bold))
+ ;; Find the current argument in the argument string. We need to
+ ;; handle `&rest' and informal `...' properly.
+ ;;
+ ;; FIXME: What to do with optional arguments, like in
+ ;; (defun NAME ARGLIST [DOCSTRING] BODY...) case?
+ ;; The problem is there is no robust way to determine if
+ ;; the current argument is indeed a docstring.
+ (while (>= index 1)
+ (if (string-match "[^ ()]+" args end)
+ (progn
+ (setq start (match-beginning 0)
+ end (match-end 0))
+ (let ((argument (match-string 0 args)))
+ (cond ((string= argument "&rest")
+ ;; All the rest arguments are the same.
+ (setq index 1))
+ ((string= argument "&optional"))
+ ((string-match "\\.\\.\\.$" argument)
+ (setq index 0))
+ (t
+ (setq index (1- index))))))
+ (setq end (length args)
+ start (1- end)
+ argument-face 'font-lock-warning-face
+ index 0)))
+ (let ((doc args))
+ (when start
+ (setq doc (copy-sequence args))
+ (add-text-properties start end (list 'face argument-face) doc))
+ (setq doc (eldoc-docstring-format-sym-doc
+ sym doc 'font-lock-function-name-face))
+ doc)))
+
;; Return a string containing a brief (one-line) documentation string for
;; the variable.
(defun eldoc-get-var-docstring (sym)
@@ -292,7 +334,8 @@ Emacs Lisp mode) that support Eldoc.")
(let ((doc (documentation-property sym 'variable-documentation t)))
(cond (doc
(setq doc (eldoc-docstring-format-sym-doc
- sym (eldoc-docstring-first-line doc)))
+ sym (eldoc-docstring-first-line doc)
+ 'font-lock-variable-name-face))
(eldoc-last-data-store sym doc 'variable)))
doc)))))
@@ -316,7 +359,7 @@ Emacs Lisp mode) that support Eldoc.")
;; 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
;; description.
-(defun eldoc-docstring-format-sym-doc (sym doc)
+(defun eldoc-docstring-format-sym-doc (sym doc face)
(save-match-data
(let* ((name (symbol-name sym))
(ea-multi eldoc-echo-area-use-multiline-p)
@@ -328,7 +371,7 @@ Emacs Lisp mode) that support Eldoc.")
(cond ((or (<= strip 0)
(eq ea-multi t)
(and ea-multi (> (length doc) ea-width)))
- (format "%s: %s" sym doc))
+ (format "%s: %s" (propertize name 'face face) doc))
((> (length doc) ea-width)
(substring (format "%s" doc) 0 ea-width))
((>= strip (length name))
@@ -338,27 +381,44 @@ Emacs Lisp mode) that support Eldoc.")
;; than the beginning, since the former is more likely
;; to be unique given package namespace conventions.
(setq name (substring name strip))
- (format "%s: %s" name doc))))))
+ (format "%s: %s" (propertize name 'face face) doc))))))
+;; Return a list of current function name and argument index.
(defun eldoc-fnsym-in-current-sexp ()
- (let ((p (point)))
- (eldoc-beginning-of-sexp)
- (prog1
- ;; Don't do anything if current word is inside a string.
- (if (= (or (char-after (1- (point))) 0) ?\")
- nil
- (eldoc-current-symbol))
- (goto-char p))))
-
+ (save-excursion
+ (let ((argument-index (1- (eldoc-beginning-of-sexp))))
+ ;; If we are at the beginning of function name, this will be -1.
+ (when (< argument-index 0)
+ (setq argument-index 0))
+ ;; Don't do anything if current word is inside a string.
+ (if (= (or (char-after (1- (point))) 0) ?\")
+ nil
+ (list (eldoc-current-symbol) argument-index)))))
+
+;; Move to the beginnig of current sexp. Return the number of nested
+;; sexp the point was over or after.
(defun eldoc-beginning-of-sexp ()
- (let ((parse-sexp-ignore-comments t))
+ (let ((parse-sexp-ignore-comments t)
+ (num-skipped-sexps 0))
(condition-case err
- (while (progn
- (forward-sexp -1)
- (or (= (char-before) ?\")
- (> (point) (point-min)))))
- (error nil))))
+ (progn
+ ;; First account for the case the point is directly over a
+ ;; beginning of a nested sexp.
+ (condition-case err
+ (let ((p (point)))
+ (forward-sexp -1)
+ (forward-sexp 1)
+ (when (< (point) p)
+ (setq num-skipped-sexps 1)))
+ (error))
+ (while
+ (let ((p (point)))
+ (forward-sexp -1)
+ (when (< (point) p)
+ (setq num-skipped-sexps (1+ num-skipped-sexps))))))
+ (error))
+ num-skipped-sexps))
;; returns nil unless current word is an interned symbol.
(defun eldoc-current-symbol ()
diff --git a/lisp/emacs-lisp/lisp-mode.el b/lisp/emacs-lisp/lisp-mode.el
index 73379a816d7..374d3ae2327 100644
--- a/lisp/emacs-lisp/lisp-mode.el
+++ b/lisp/emacs-lisp/lisp-mode.el
@@ -730,7 +730,9 @@ If the current defun is actually a call to `defvar' or `defcustom',
evaluating it this way resets the variable using its initial value
expression even if the variable already has some other value.
\(Normally `defvar' and `defcustom' do not alter the value if there
-already is one.)
+already is one.) In an analogous way, evaluating a `defface'
+overrides any customizations of the face, so that it becomes
+defined exactly as the `defface' expression says.
If `eval-expression-debug-on-error' is non-nil, which is the default,
this command arranges for all errors to enter the debugger.