summaryrefslogtreecommitdiff
path: root/lisp/emacs-lisp
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/emacs-lisp')
-rw-r--r--lisp/emacs-lisp/byte-opt.el3
-rw-r--r--lisp/emacs-lisp/easy-mmode.el26
-rw-r--r--lisp/emacs-lisp/easymenu.el4
-rw-r--r--lisp/emacs-lisp/syntax.el1
-rw-r--r--lisp/emacs-lisp/timer.el54
5 files changed, 62 insertions, 26 deletions
diff --git a/lisp/emacs-lisp/byte-opt.el b/lisp/emacs-lisp/byte-opt.el
index 7d47d809673..8711a05e2d9 100644
--- a/lisp/emacs-lisp/byte-opt.el
+++ b/lisp/emacs-lisp/byte-opt.el
@@ -1121,6 +1121,7 @@
(put 'symbol-name 'byte-optimizer 'byte-optimize-pure-func)
(put 'regexp-opt 'byte-optimizer 'byte-optimize-pure-func)
(put 'regexp-quote 'byte-optimizer 'byte-optimize-pure-func)
+(put 'string-to-syntax 'byte-optimizer 'byte-optimize-pure-func)
(defun byte-optimize-pure-func (form)
"Do constant folding for pure functions.
This assumes that the function will not have any side-effects and that
@@ -1134,7 +1135,7 @@ of FORM by signaling the error at compile-time."
(setq constant nil))
(setq args (cdr args)))
(if constant
- (eval form)
+ (list 'quote (eval form))
form)))
;; Avoid having to write forward-... with a negative arg for speed.
diff --git a/lisp/emacs-lisp/easy-mmode.el b/lisp/emacs-lisp/easy-mmode.el
index da0ca735efd..710c26e0c6c 100644
--- a/lisp/emacs-lisp/easy-mmode.el
+++ b/lisp/emacs-lisp/easy-mmode.el
@@ -272,8 +272,14 @@ With zero or negative ARG turn mode off.
"Make GLOBAL-MODE out of the buffer-local minor MODE.
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.
+KEYS is a list of CL-style keyword arguments. As the minor mode
+ defined by this function is always global, any :global keyword is
+ ignored. Other keywords have the same meaning as in `define-minor-mode',
+ which see. In particular, :group specifies the custom group.
+ The most useful keywords are those that are passed on to the
+ `defcustom'. It normally makes no sense to pass the :lighter
+ or :keymap keywords to `define-global-minor-mode', since these
+ are usually passed to the buffer-local version of the minor mode.
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
@@ -285,21 +291,23 @@ call another major mode in their body."
(pretty-name (easy-mmode-pretty-mode-name mode))
(pretty-global-name (easy-mmode-pretty-mode-name global-mode))
(group nil)
- (extra-args nil)
+ (extra-keywords nil)
(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"))))
+ (MODE-major-mode (intern (concat (symbol-name mode) "-major-mode")))
+ keyw)
;; Check keys.
- (while (keywordp (car keys))
- (case (pop keys)
- (:extra-args (setq extra-args (pop keys)))
+ (while (keywordp (setq keyw (car keys)))
+ (setq keys (cdr keys))
+ (case keyw
(:group (setq group (nconc group (list :group (pop keys)))))
- (t (setq keys (cdr keys)))))
+ (:global (setq keys (cdr keys)))
+ (t (push keyw extra-keywords) (push (pop keys) extra-keywords))))
(unless group
;; We might as well provide a best-guess default group.
@@ -317,7 +325,7 @@ With prefix ARG, turn %s on if and only if ARG is positive.
%s is actually not turned on in every buffer but only in those
in which `%s' turns it on."
pretty-name pretty-global-name pretty-name turn-on)
- :global t :extra-args ,extra-args ,@group
+ :global t ,@group ,@(nreverse extra-keywords)
;; Setup hook to handle future mode changes and new buffers.
(if ,global-mode
diff --git a/lisp/emacs-lisp/easymenu.el b/lisp/emacs-lisp/easymenu.el
index 634c2397411..65826290851 100644
--- a/lisp/emacs-lisp/easymenu.el
+++ b/lisp/emacs-lisp/easymenu.el
@@ -454,8 +454,8 @@ If the menu located by PATH has no submenu named NAME, add one.
If the optional argument BEFORE is present, add it just before
the submenu named BEFORE, otherwise add it at the end of the menu.
-Either call this from `menu-bar-update-hook' or use a menu filter,
-to implement dynamic menus."
+To implement dynamic menus, either call this from
+`menu-bar-update-hook' or use a menu filter."
(easy-menu-add-item nil path (easy-menu-create-menu name items) before))
;; XEmacs needs the following two functions to add and remove menus.
diff --git a/lisp/emacs-lisp/syntax.el b/lisp/emacs-lisp/syntax.el
index 9c2ac336b9b..feccf7939c5 100644
--- a/lisp/emacs-lisp/syntax.el
+++ b/lisp/emacs-lisp/syntax.el
@@ -109,7 +109,6 @@ point (where the PPSS is equivalent to nil).")
(error nil)))
syntax-ppss-stats))
-;;;###autoload
(defun syntax-ppss (&optional pos)
"Parse-Partial-Sexp State at POS.
The returned value is the same as `parse-partial-sexp' except that
diff --git a/lisp/emacs-lisp/timer.el b/lisp/emacs-lisp/timer.el
index 83b01642c56..2aa30220f4f 100644
--- a/lisp/emacs-lisp/timer.el
+++ b/lisp/emacs-lisp/timer.el
@@ -161,8 +161,11 @@ fire repeatedly that many seconds apart."
(aset timer 6 args)
timer)
-(defun timer-activate (timer &optional triggered-p)
- "Put TIMER on the list of active timers."
+(defun timer-activate (timer &optional triggered-p reuse-cell)
+ "Put TIMER on the list of active timers.
+
+REUSE-CELL, if non-nil, is a cons cell to reuse instead
+of allocating a new one."
(if (and (timerp timer)
(integerp (aref timer 1))
(integerp (aref timer 2))
@@ -180,20 +183,28 @@ fire repeatedly that many seconds apart."
(> (aref timer 3) (aref (car timers) 3)))))
(setq last timers
timers (cdr timers)))
+ (if reuse-cell
+ (progn
+ (setcar reuse-cell timer)
+ (setcdr reuse-cell timers))
+ (setq reuse-cell (cons timer timers)))
;; Insert new timer after last which possibly means in front of queue.
(if last
- (setcdr last (cons timer timers))
- (setq timer-list (cons timer timers)))
+ (setcdr last reuse-cell)
+ (setq timer-list reuse-cell))
(aset timer 0 triggered-p)
(aset timer 7 nil)
nil)
(error "Invalid or uninitialized timer")))
-(defun timer-activate-when-idle (timer &optional dont-wait)
+(defun timer-activate-when-idle (timer &optional dont-wait reuse-cell)
"Arrange to activate TIMER whenever Emacs is next idle.
If optional argument DONT-WAIT is non-nil, then enable the
timer to activate immediately, or at the right time, if Emacs
-is already idle."
+is already idle.
+
+REUSE-CELL, if non-nil, is a cons cell to reuse instead
+of allocating a new one."
(if (and (timerp timer)
(integerp (aref timer 1))
(integerp (aref timer 2))
@@ -211,10 +222,15 @@ is already idle."
(> (aref timer 3) (aref (car timers) 3)))))
(setq last timers
timers (cdr timers)))
+ (if reuse-cell
+ (progn
+ (setcar reuse-cell timer)
+ (setcdr reuse-cell timers))
+ (setq reuse-cell (cons timer timers)))
;; Insert new timer after last which possibly means in front of queue.
(if last
- (setcdr last (cons timer timers))
- (setq timer-idle-list (cons timer timers)))
+ (setcdr last reuse-cell)
+ (setq timer-idle-list reuse-cell))
(aset timer 0 (not dont-wait))
(aset timer 7 t)
nil)
@@ -231,6 +247,18 @@ is already idle."
(setq timer-idle-list (delq timer timer-idle-list))
nil)
+;; Remove TIMER from the list of active timers or idle timers.
+;; Only to be used in this file. It returns the cons cell
+;; that was removed from the list.
+(defun cancel-timer-internal (timer)
+ (let ((cell1 (memq timer timer-list))
+ (cell2 (memq timer timer-idle-list)))
+ (if cell1
+ (setq timer-list (delq timer timer-list)))
+ (if cell2
+ (setq timer-idle-list (delq timer timer-idle-list)))
+ (or cell1 cell2)))
+
;;;###autoload
(defun cancel-function-timers (function)
"Cancel all timers scheduled by `run-at-time' which would run FUNCTION."
@@ -270,13 +298,13 @@ This function is called, by name, directly by the C code."
(setq timer-event-last timer)
(let ((inhibit-quit t))
(if (timerp timer)
- (let (retrigger)
- ;; Delete from queue.
- (cancel-timer timer)
+ (let (retrigger cell)
+ ;; Delete from queue. Record the cons cell that was used.
+ (setq cell (cancel-timer-internal timer))
;; Re-schedule if requested.
(if (aref timer 4)
(if (aref timer 7)
- (timer-activate-when-idle timer)
+ (timer-activate-when-idle timer nil cell)
(timer-inc-time timer (aref timer 4) 0)
;; If real time has jumped forward,
;; perhaps because Emacs was suspended for a long time,
@@ -287,7 +315,7 @@ This function is called, by name, directly by the C code."
(aref timer 4))))
(if (> repeats timer-max-repeats)
(timer-inc-time timer (* (aref timer 4) repeats)))))
- (timer-activate timer t)
+ (timer-activate timer t cell)
(setq retrigger t)))
;; Run handler.
;; We do this after rescheduling so that the handler function