summaryrefslogtreecommitdiff
path: root/lisp/emacs-lisp
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/emacs-lisp')
-rw-r--r--lisp/emacs-lisp/bytecomp.el18
-rw-r--r--lisp/emacs-lisp/cl-macs.el11
-rw-r--r--lisp/emacs-lisp/easy-mmode.el66
-rw-r--r--lisp/emacs-lisp/easymenu.el14
-rw-r--r--lisp/emacs-lisp/find-func.el4
-rw-r--r--lisp/emacs-lisp/re-builder.el2
6 files changed, 79 insertions, 36 deletions
diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el
index aab4efab9f8..16ade261344 100644
--- a/lisp/emacs-lisp/bytecomp.el
+++ b/lisp/emacs-lisp/bytecomp.el
@@ -1248,15 +1248,15 @@ extra args."
(defun byte-compile-nogroup-warn (form)
(let ((keyword-args (cdr (cdr (cdr (cdr form)))))
(name (cadr form)))
- (unless (plist-get keyword-args :group)
- (byte-compile-warn
- "%s for `%s' fails to specify containing group"
- (cdr (assq (car form)
- '((custom-declare-group . defgroup)
- (custom-declare-face . defface)
- (custom-declare-variable . defcustom))))
- (if (and (consp name) (eq (car name) 'quote))
- (cadr name) name)))))
+ (or (plist-get keyword-args :group)
+ (not (and (consp name) (eq (car name) 'quote)))
+ (byte-compile-warn
+ "%s for `%s' fails to specify containing group"
+ (cdr (assq (car form)
+ '((custom-declare-group . defgroup)
+ (custom-declare-face . defface)
+ (custom-declare-variable . defcustom))))
+ (cadr name)))))
;; Warn if the function or macro is being redefined with a different
;; number of arguments.
diff --git a/lisp/emacs-lisp/cl-macs.el b/lisp/emacs-lisp/cl-macs.el
index 1be2f9171a6..c47c306e014 100644
--- a/lisp/emacs-lisp/cl-macs.el
+++ b/lisp/emacs-lisp/cl-macs.el
@@ -1565,14 +1565,21 @@ form. See `defsetf' for a simpler way to define most setf-methods.
This macro is an easy-to-use substitute for `define-setf-method' that works
well for simple place forms. In the simple `defsetf' form, `setf's of
the form (setf (NAME ARGS...) VAL) are transformed to function or macro
-calls of the form (FUNC ARGS... VAL). Example: (defsetf aref aset).
+calls of the form (FUNC ARGS... VAL). Example:
+
+ (defsetf aref aset)
+
Alternate form: (defsetf NAME ARGLIST (STORE) BODY...).
Here, the above `setf' call is expanded by binding the argument forms ARGS
according to ARGLIST, binding the value form VAL to STORE, then executing
BODY, which must return a Lisp form that does the necessary `setf' operation.
Actually, ARGLIST and STORE may be bound to temporary variables which are
introduced automatically to preserve proper execution order of the arguments.
-Example: (defsetf nth (n x) (v) (list 'setcar (list 'nthcdr n x) v))."
+Example:
+
+ (defsetf nth (n x) (v) (list 'setcar (list 'nthcdr n x) v))
+
+\(fn NAME [FUNC | ARGLIST (STORE) BODY...])"
(if (listp arg1)
(let* ((largs nil) (largsr nil)
(temps nil) (tempsr nil)
diff --git a/lisp/emacs-lisp/easy-mmode.el b/lisp/emacs-lisp/easy-mmode.el
index 188dc172e07..bb0fa666217 100644
--- a/lisp/emacs-lisp/easy-mmode.el
+++ b/lisp/emacs-lisp/easy-mmode.el
@@ -271,14 +271,26 @@ With zero or negative ARG turn mode off.
TURN-ON is a function that will be called with no args in every buffer
and that should try to turn MODE on if applicable for that buffer.
KEYS is a list of CL-style keyword arguments:
-:group to specify the custom group."
+:group to specify the custom group.
+
+If MODE's set-up depends on the major mode in effect when it was
+enabled, then disabling and reenabling MODE should make MODE work
+correctly with the current major mode. This is important to
+prevent problems with derived modes, that is, major modes that
+call another major mode in their body."
+
(let* ((global-mode-name (symbol-name global-mode))
(pretty-name (easy-mmode-pretty-mode-name mode))
(pretty-global-name (easy-mmode-pretty-mode-name global-mode))
(group nil)
(extra-args nil)
- (buffers (intern (concat global-mode-name "-buffers")))
- (cmmh (intern (concat global-mode-name "-cmmh"))))
+ (MODE-buffers (intern (concat global-mode-name "-buffers")))
+ (MODE-enable-in-buffers
+ (intern (concat global-mode-name "-enable-in-buffers")))
+ (MODE-check-buffers
+ (intern (concat global-mode-name "-check-buffers")))
+ (MODE-cmhh (intern (concat global-mode-name "-cmhh")))
+ (MODE-major-mode (intern (concat (symbol-name mode) "-major-mode"))))
;; Check keys.
(while (keywordp (car keys))
@@ -294,6 +306,8 @@ KEYS is a list of CL-style keyword arguments:
"-mode\\'" "" (symbol-name mode))))))
`(progn
+ (defvar ,MODE-major-mode nil)
+ (make-variable-buffer-local ',MODE-major-mode)
;; The actual global minor-mode
(define-minor-mode ,global-mode
,(format "Toggle %s in every buffer.
@@ -306,10 +320,13 @@ in which `%s' turns it on."
;; Setup hook to handle future mode changes and new buffers.
(if ,global-mode
(progn
- (add-hook 'after-change-major-mode-hook ',buffers)
- (add-hook 'change-major-mode-hook ',cmmh))
- (remove-hook 'after-change-major-mode-hook ',buffers)
- (remove-hook 'change-major-mode-hook ',cmmh))
+ (add-hook 'after-change-major-mode-hook
+ ',MODE-enable-in-buffers)
+ (add-hook 'find-file-hook ',MODE-check-buffers)
+ (add-hook 'change-major-mode-hook ',MODE-cmhh))
+ (remove-hook 'after-change-major-mode-hook ',MODE-enable-in-buffers)
+ (remove-hook 'find-file-hook ',MODE-check-buffers)
+ (remove-hook 'change-major-mode-hook ',MODE-cmhh))
;; Go through existing buffers.
(dolist (buf (buffer-list))
@@ -321,22 +338,33 @@ in which `%s' turns it on."
:autoload-end
;; List of buffers left to process.
- (defvar ,buffers nil)
+ (defvar ,MODE-buffers nil)
;; The function that calls TURN-ON in each buffer.
- (defun ,buffers ()
- (remove-hook 'post-command-hook ',buffers)
- (while ,buffers
- (let ((buf (pop ,buffers)))
- (when (buffer-live-p buf)
- (with-current-buffer buf (,turn-on))))))
- (put ',buffers 'definition-name ',global-mode)
+ (defun ,MODE-enable-in-buffers ()
+ (dolist (buf ,MODE-buffers)
+ (when (buffer-live-p buf)
+ (with-current-buffer buf
+ (if ,mode
+ (unless (eq ,MODE-major-mode major-mode)
+ (,mode -1)
+ (,turn-on)
+ (setq ,MODE-major-mode major-mode))
+ (,turn-on)
+ (setq ,MODE-major-mode major-mode))))))
+ (put ',MODE-enable-in-buffers 'definition-name ',global-mode)
+
+ (defun ,MODE-check-buffers ()
+ (,MODE-enable-in-buffers)
+ (setq ,MODE-buffers nil)
+ (remove-hook 'post-command-hook ',MODE-check-buffers))
+ (put ',MODE-check-buffers 'definition-name ',global-mode)
;; The function that catches kill-all-local-variables.
- (defun ,cmmh ()
- (add-to-list ',buffers (current-buffer))
- (add-hook 'post-command-hook ',buffers))
- (put ',cmmh 'definition-name ',global-mode))))
+ (defun ,MODE-cmhh ()
+ (add-to-list ',MODE-buffers (current-buffer))
+ (add-hook 'post-command-hook ',MODE-check-buffers))
+ (put ',MODE-cmhh 'definition-name ',global-mode))))
;;;
;;; easy-mmode-defmap
diff --git a/lisp/emacs-lisp/easymenu.el b/lisp/emacs-lisp/easymenu.el
index b3160c9b752..982570fb348 100644
--- a/lisp/emacs-lisp/easymenu.el
+++ b/lisp/emacs-lisp/easymenu.el
@@ -1,6 +1,7 @@
;;; easymenu.el --- support the easymenu interface for defining a menu
-;; Copyright (C) 1994,96,98,1999,2000,2004 Free Software Foundation, Inc.
+;; Copyright (C) 1994, 1996, 1998, 1999, 2000, 2004, 2005
+;; Free Software Foundation, Inc.
;; Keywords: emulations
;; Author: Richard Stallman <rms@gnu.org>
@@ -534,7 +535,7 @@ earlier by `easy-menu-define' or `easy-menu-create-menu'."
(easy-menu-do-add-item map item before)))
(defun easy-menu-item-present-p (map path name)
- "In submenu of MAP with path PATH, return true iff item NAME is present.
+ "In submenu of MAP with path PATH, return non-nil iff item NAME is present.
MAP and PATH are defined as in `easy-menu-add-item'.
NAME should be a string, the name of the element to be looked for."
(easy-menu-return-item (easy-menu-get-map map path) name))
@@ -552,7 +553,14 @@ NAME should be a string, the name of the element to be removed."
"In menu MENU try to look for menu item with name NAME.
If a menu item is found, return (NAME . item), otherwise return nil.
If item is an old format item, a new format item is returned."
- (let ((item (lookup-key menu (vector (easy-menu-intern name))))
+ ;; The call to `lookup-key' also calls the C function `get_keyelt' which
+ ;; looks inside a menu-item to only return the actual command. This is
+ ;; not what we want here. We should either add an arg to lookup-key to be
+ ;; able to turn off this "feature", or else we could use map-keymap here.
+ ;; In the mean time, I just use `assq' which is an OK approximation since
+ ;; menus are rarely built from vectors or char-tables.
+ (let ((item (or (cdr (assq name menu))
+ (lookup-key menu (vector (easy-menu-intern name)))))
ret enable cache label)
(cond
((stringp (car-safe item))
diff --git a/lisp/emacs-lisp/find-func.el b/lisp/emacs-lisp/find-func.el
index eab957e5671..9a0a1606953 100644
--- a/lisp/emacs-lisp/find-func.el
+++ b/lisp/emacs-lisp/find-func.el
@@ -246,8 +246,6 @@ searched for in `find-function-source-path' if non nil, otherwise
in `load-path'."
(if (not function)
(error "You didn't specify a function"))
- (and (subrp (symbol-function function))
- (error "%s is a primitive function" function))
(let ((def (symbol-function function))
aliases)
(while (symbolp def)
@@ -265,6 +263,8 @@ in `load-path'."
(let ((library
(cond ((eq (car-safe def) 'autoload)
(nth 1 def))
+ ((subrp def)
+ (help-C-file-name def 'subr))
((symbol-file function 'defun)))))
(find-function-search-for-symbol function nil library))))
diff --git a/lisp/emacs-lisp/re-builder.el b/lisp/emacs-lisp/re-builder.el
index a2aed39d00a..8a53c202ed8 100644
--- a/lisp/emacs-lisp/re-builder.el
+++ b/lisp/emacs-lisp/re-builder.el
@@ -254,7 +254,7 @@ Except for Lisp syntax this is the same as `reb-regexp'.")
mode-name "RE Builder")
(use-local-map reb-mode-map)
(reb-mode-common)
- (run-hooks 'reb-mode-hook))
+ (run-mode-hooks 'reb-mode-hook))
(define-derived-mode reb-lisp-mode
emacs-lisp-mode "RE Builder Lisp"