aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Eggert2011-10-26 00:31:15 -0700
committerPaul Eggert2011-10-26 00:31:15 -0700
commitc03500e05a53e1717a7cd659bbe085014507eadd (patch)
tree6bc3699c4adebb9d173578086756c1582f96e373
parent225a2cff910d3fbc2cca2cdef6d3eecfce9e74e5 (diff)
parent71d4c2a518e58b37f42c0d57e5c0507af5792133 (diff)
downloademacs-c03500e05a53e1717a7cd659bbe085014507eadd.tar.gz
emacs-c03500e05a53e1717a7cd659bbe085014507eadd.zip
Merge from trunk.
-rw-r--r--doc/lispref/ChangeLog4
-rw-r--r--doc/lispref/modes.texi54
-rw-r--r--etc/NEWS8
-rw-r--r--lisp/ChangeLog9
-rw-r--r--lisp/progmodes/octave-inf.el3
-rw-r--r--lisp/progmodes/octave-mod.el4
-rw-r--r--lisp/subr.el40
-rw-r--r--src/intervals.c2
8 files changed, 87 insertions, 37 deletions
diff --git a/doc/lispref/ChangeLog b/doc/lispref/ChangeLog
index 490280dae29..acc334ea000 100644
--- a/doc/lispref/ChangeLog
+++ b/doc/lispref/ChangeLog
@@ -1,3 +1,7 @@
12011-10-26 Chong Yidong <cyd@gnu.org>
2
3 * modes.texi (Running Hooks): Document with-wrapper-hook.
4
12011-10-18 Chong Yidong <cyd@gnu.org> 52011-10-18 Chong Yidong <cyd@gnu.org>
2 6
3 * display.texi (Glyphless Chars): New node. 7 * display.texi (Glyphless Chars): New node.
diff --git a/doc/lispref/modes.texi b/doc/lispref/modes.texi
index eb81ebc4acb..9d652901e53 100644
--- a/doc/lispref/modes.texi
+++ b/doc/lispref/modes.texi
@@ -84,8 +84,9 @@ its value is just a single function, not a list of functions.
84@node Running Hooks 84@node Running Hooks
85@subsection Running Hooks 85@subsection Running Hooks
86 86
87 At the appropriate times, Emacs uses the @code{run-hooks} function 87 In this section, we document the @code{run-hooks} function, which is
88and the other functions below to run particular hooks. 88used to run a normal hook. We also document the functions for running
89various kinds of abnormal hooks.
89 90
90@defun run-hooks &rest hookvars 91@defun run-hooks &rest hookvars
91This function takes one or more normal hook variable names as 92This function takes one or more normal hook variable names as
@@ -108,28 +109,49 @@ be run as well.
108@end defun 109@end defun
109 110
110@defun run-hook-with-args hook &rest args 111@defun run-hook-with-args hook &rest args
111This function is the way to run an abnormal hook and always call all 112This function runs an abnormal hook by calling all the hook functions in
112of the hook functions. It calls each of the hook functions one by 113@var{hook}, passing each one the arguments @var{args}.
113one, passing each of them the arguments @var{args}.
114@end defun 114@end defun
115 115
116@defun run-hook-with-args-until-failure hook &rest args 116@defun run-hook-with-args-until-failure hook &rest args
117This function is the way to run an abnormal hook until one of the hook 117This function runs an abnormal hook by calling each hook function in
118functions fails. It calls each of the hook functions, passing each of 118turn, stopping if one of them ``fails'' by returning @code{nil}. Each
119them the arguments @var{args}, until some hook function returns 119hook function is passed the arguments @var{args}. If this function
120@code{nil}. It then stops and returns @code{nil}. If none of the 120stops because one of the hook functions fails, it returns @code{nil};
121hook functions return @code{nil}, it returns a non-@code{nil} value. 121otherwise it returns a non-@code{nil} value.
122@end defun 122@end defun
123 123
124@defun run-hook-with-args-until-success hook &rest args 124@defun run-hook-with-args-until-success hook &rest args
125This function is the way to run an abnormal hook until a hook function 125This function runs an abnormal hook by calling each hook function,
126succeeds. It calls each of the hook functions, passing each of them 126stopping if one of them ``succeeds'' by returning a non-@code{nil}
127the arguments @var{args}, until some hook function returns 127value. Each hook function is passed the arguments @var{args}. If this
128non-@code{nil}. Then it stops, and returns whatever was returned by 128function stops because one of the hook functions returns a
129the last hook function that was called. If all hook functions return 129non-@code{nil} value, it returns that value; otherwise it returns
130@code{nil}, it returns @code{nil} as well. 130@code{nil}.
131@end defun 131@end defun
132 132
133@defmac with-wrapper-hook hook args &rest body
134This macro runs the abnormal hook @code{hook} as a series of nested
135``wrapper functions'' around the @var{body} forms. The effect is
136similar to nested @code{around} advices (@pxref{Around-Advice}).
137
138Each hook function must accept an argument list consisting of a function
139@var{fun}, followed by the additional arguments listed in @var{args}.
140The function @var{fun} passed to the very first hook function in
141@var{hook} does the same as @var{body}, if it is called with arguments
142@var{args}. The @var{fun} passed to each successive hook function is
143constructed from all the preceding hook functions (and @var{body}); if
144this @var{fun} is called with arguments @var{args}, it does what the
145@code{with-wrapper-hook} call would if the preceding hook functions were
146the only ones in @var{hook}.
147
148In the function definition of the hook function, @var{fun} can be called
149any number of times (including not calling it at all). This function
150definition is then used to construct the @var{fun} passed to the next
151hook function in @var{hook}, if any. The last or ``outermost''
152@var{fun} is called once to produce the effect.
153@end defmac
154
133@node Setting Hooks 155@node Setting Hooks
134@subsection Setting Hooks 156@subsection Setting Hooks
135 157
diff --git a/etc/NEWS b/etc/NEWS
index d6b0bdb484c..58f3fa492e2 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -1169,7 +1169,13 @@ must also be supplied.
1169** pre/post-command-hook are not reset to nil upon error. 1169** pre/post-command-hook are not reset to nil upon error.
1170Instead, the offending function is removed. 1170Instead, the offending function is removed.
1171 1171
1172** New low-level function run-hook-wrapped. 1172** New hook types
1173
1174*** New function `run-hook-wrapped' for running an abnormal hook by
1175passing the hook functions as arguments to a "wrapping" function.
1176+++
1177*** New macro `with-wrapper-hook' for running an abnormal hook as a
1178set of "wrapping" filters, similar to around advice.
1173 1179
1174** `server-eval-at' is provided to allow evaluating forms on different 1180** `server-eval-at' is provided to allow evaluating forms on different
1175Emacs server instances. 1181Emacs server instances.
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 95113007f27..60f1db123cf 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,12 @@
12011-10-26 Stefan Monnier <monnier@iro.umontreal.ca>
2
3 * progmodes/octave-mod.el:
4 * progmodes/octave-inf.el: Update maintainer.
5
62011-10-26 Chong Yidong <cyd@gnu.org>
7
8 * subr.el (with-wrapper-hook): Rewrite doc.
9
12011-10-25 Michael Albinus <michael.albinus@gmx.de> 102011-10-25 Michael Albinus <michael.albinus@gmx.de>
2 11
3 * net/tramp-sh.el (tramp-sh-handle-file-directory-p): Return t for 12 * net/tramp-sh.el (tramp-sh-handle-file-directory-p): Return t for
diff --git a/lisp/progmodes/octave-inf.el b/lisp/progmodes/octave-inf.el
index e9d890c3f26..421f476016e 100644
--- a/lisp/progmodes/octave-inf.el
+++ b/lisp/progmodes/octave-inf.el
@@ -4,7 +4,7 @@
4 4
5;; Author: Kurt Hornik <Kurt.Hornik@wu-wien.ac.at> 5;; Author: Kurt Hornik <Kurt.Hornik@wu-wien.ac.at>
6;; Author: John Eaton <jwe@bevo.che.wisc.edu> 6;; Author: John Eaton <jwe@bevo.che.wisc.edu>
7;; Maintainer: Kurt Hornik <Kurt.Hornik@wu-wien.ac.at> 7;; Maintainer: FSF
8;; Keywords: languages 8;; Keywords: languages
9;; Package: octave-mod 9;; Package: octave-mod
10 10
@@ -68,6 +68,7 @@ mode, set this to (\"-q\" \"--traditional\")."
68 (define-key map "\C-c\C-l" 'inferior-octave-dynamic-list-input-ring) 68 (define-key map "\C-c\C-l" 'inferior-octave-dynamic-list-input-ring)
69 (define-key map [menu-bar inout list-history] 69 (define-key map [menu-bar inout list-history]
70 '("List Input History" . inferior-octave-dynamic-list-input-ring)) 70 '("List Input History" . inferior-octave-dynamic-list-input-ring))
71 ;; FIXME: free C-h so it can do the describe-prefix-bindings.
71 (define-key map "\C-c\C-h" 'info-lookup-symbol) 72 (define-key map "\C-c\C-h" 'info-lookup-symbol)
72 map) 73 map)
73 "Keymap used in Inferior Octave mode.") 74 "Keymap used in Inferior Octave mode.")
diff --git a/lisp/progmodes/octave-mod.el b/lisp/progmodes/octave-mod.el
index 5e13b8533e7..28e25a35c70 100644
--- a/lisp/progmodes/octave-mod.el
+++ b/lisp/progmodes/octave-mod.el
@@ -4,7 +4,7 @@
4 4
5;; Author: Kurt Hornik <Kurt.Hornik@wu-wien.ac.at> 5;; Author: Kurt Hornik <Kurt.Hornik@wu-wien.ac.at>
6;; Author: John Eaton <jwe@octave.org> 6;; Author: John Eaton <jwe@octave.org>
7;; Maintainer: Kurt Hornik <Kurt.Hornik@wu-wien.ac.at> 7;; Maintainer: FSF
8;; Keywords: languages 8;; Keywords: languages
9 9
10;; This file is part of GNU Emacs. 10;; This file is part of GNU Emacs.
@@ -223,6 +223,7 @@ parenthetical grouping.")
223 (define-key map "\C-c]" 'smie-close-block) 223 (define-key map "\C-c]" 'smie-close-block)
224 (define-key map "\C-c/" 'smie-close-block) 224 (define-key map "\C-c/" 'smie-close-block)
225 (define-key map "\C-c\C-f" 'octave-insert-defun) 225 (define-key map "\C-c\C-f" 'octave-insert-defun)
226 ;; FIXME: free C-h so it can do the describe-prefix-bindings.
226 (define-key map "\C-c\C-h" 'info-lookup-symbol) 227 (define-key map "\C-c\C-h" 'info-lookup-symbol)
227 (define-key map "\C-c\C-il" 'octave-send-line) 228 (define-key map "\C-c\C-il" 'octave-send-line)
228 (define-key map "\C-c\C-ib" 'octave-send-block) 229 (define-key map "\C-c\C-ib" 'octave-send-block)
@@ -236,6 +237,7 @@ parenthetical grouping.")
236 (define-key map "\C-c\C-i\C-f" 'octave-send-defun) 237 (define-key map "\C-c\C-i\C-f" 'octave-send-defun)
237 (define-key map "\C-c\C-i\C-r" 'octave-send-region) 238 (define-key map "\C-c\C-i\C-r" 'octave-send-region)
238 (define-key map "\C-c\C-i\C-s" 'octave-show-process-buffer) 239 (define-key map "\C-c\C-i\C-s" 'octave-show-process-buffer)
240 ;; FIXME: free C-h so it can do the describe-prefix-bindings.
239 (define-key map "\C-c\C-i\C-h" 'octave-hide-process-buffer) 241 (define-key map "\C-c\C-i\C-h" 'octave-hide-process-buffer)
240 (define-key map "\C-c\C-i\C-k" 'octave-kill-process) 242 (define-key map "\C-c\C-i\C-k" 'octave-kill-process)
241 map) 243 map)
diff --git a/lisp/subr.el b/lisp/subr.el
index c88cef0ba0f..7ac287d2473 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -1364,18 +1364,26 @@ All symbols are bound before the VALUEFORMs are evalled."
1364 ,@(mapcar (lambda (binder) `(setq ,@binder)) binders) 1364 ,@(mapcar (lambda (binder) `(setq ,@binder)) binders)
1365 ,@body)) 1365 ,@body))
1366 1366
1367(defmacro with-wrapper-hook (var args &rest body) 1367(defmacro with-wrapper-hook (hook args &rest body)
1368 "Run BODY wrapped with the VAR hook. 1368 "Run BODY, using wrapper functions from HOOK with additional ARGS.
1369VAR is a special hook: its functions are called with a first argument 1369HOOK is an abnormal hook. Each hook function in HOOK \"wraps\"
1370which is the \"original\" code (the BODY), so the hook function can wrap 1370around the preceding ones, like a set of nested `around' advices.
1371the original function, or call it any number of times (including not calling 1371
1372it at all). This is similar to an `around' advice. 1372Each hook function should accept an argument list consisting of a
1373VAR is normally a symbol (a variable) in which case it is treated like 1373function FUN, followed by the additional arguments in ARGS.
1374a hook, with a buffer-local and a global part. But it can also be an 1374
1375arbitrary expression. 1375The FUN passed to the first hook function in HOOK performs BODY,
1376ARGS is a list of variables which will be passed as additional arguments 1376if it is called with arguments ARGS. The FUN passed to each
1377to each function, after the initial argument, and which the first argument 1377successive hook function is defined based on the preceding hook
1378expects to receive when called." 1378functions; if called with arguments ARGS, it does what the
1379`with-wrapper-hook' call would do if the preceding hook functions
1380were the only ones present in HOOK.
1381
1382In the function definition of each hook function, FUN can be
1383called any number of times (including not calling it at all).
1384That function definition is then used to construct the FUN passed
1385to the next hook function, if any. The last (or \"outermost\")
1386FUN is then called once."
1379 (declare (indent 2) (debug (form sexp body))) 1387 (declare (indent 2) (debug (form sexp body)))
1380 ;; We need those two gensyms because CL's lexical scoping is not available 1388 ;; We need those two gensyms because CL's lexical scoping is not available
1381 ;; for function arguments :-( 1389 ;; for function arguments :-(
@@ -1404,11 +1412,11 @@ expects to receive when called."
1404 ;; Once there are no more functions on the hook, run 1412 ;; Once there are no more functions on the hook, run
1405 ;; the original body. 1413 ;; the original body.
1406 (apply (lambda ,args ,@body) ,argssym))))) 1414 (apply (lambda ,args ,@body) ,argssym)))))
1407 (funcall ,runrestofhook ,var 1415 (funcall ,runrestofhook ,hook
1408 ;; The global part of the hook, if any. 1416 ;; The global part of the hook, if any.
1409 ,(if (symbolp var) 1417 ,(if (symbolp hook)
1410 `(if (local-variable-p ',var) 1418 `(if (local-variable-p ',hook)
1411 (default-value ',var))) 1419 (default-value ',hook)))
1412 (list ,@args))))) 1420 (list ,@args)))))
1413 1421
1414(defun add-to-list (list-var element &optional append compare-fn) 1422(defun add-to-list (list-var element &optional append compare-fn)
diff --git a/src/intervals.c b/src/intervals.c
index dd511252b28..e8ff5bce5b6 100644
--- a/src/intervals.c
+++ b/src/intervals.c
@@ -1723,8 +1723,6 @@ graft_intervals_into_buffer (INTERVAL source, ptrdiff_t position,
1723 BUF_INTERVALS (buffer)->position = BEG; 1723 BUF_INTERVALS (buffer)->position = BEG;
1724 BUF_INTERVALS (buffer)->up_obj = 1; 1724 BUF_INTERVALS (buffer)->up_obj = 1;
1725 1725
1726 /* Explicitly free the old tree here? */
1727
1728 return; 1726 return;
1729 } 1727 }
1730 1728