* Changing occur-hook to occur-functions @ 2005-07-02 18:40 Juanma Barranquero 2005-07-02 19:01 ` Juanma Barranquero 0 siblings, 1 reply; 15+ messages in thread From: Juanma Barranquero @ 2005-07-02 18:40 UTC (permalink / raw) I'd like to change `occur-hook' to `occur-functions', and pass it the current occur buffer (which can be different of "*Occur*"). This is not an incompatible change, as `occur-hook' is not in 21.4. -- /L/e/k/t/u Index: lisp/replace.el =================================================================== RCS file: /cvsroot/emacs/emacs/lisp/replace.el,v retrieving revision 1.216 diff -r1.216 replace.el 721,722c721,723 < (defcustom occur-hook nil < "Hook run when `occur' is called." --- > (defcustom occur-functions nil > "List of functions run when `occur' is called. > Each function is passed one argument, the Occur mode buffer." 1052c1053 < (run-hooks 'occur-hook))))) --- > (run-hook-with-args 'occur-functions occur-buf))))) ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Changing occur-hook to occur-functions 2005-07-02 18:40 Changing occur-hook to occur-functions Juanma Barranquero @ 2005-07-02 19:01 ` Juanma Barranquero 2005-07-03 20:42 ` Richard M. Stallman ` (2 more replies) 0 siblings, 3 replies; 15+ messages in thread From: Juanma Barranquero @ 2005-07-02 19:01 UTC (permalink / raw) While still on Occur, another little issue: the documentation of `occur-rename-buffer' talks about adding it to `occur-mode-hook' (it used to say to add it to `occur-hook', but that was a mistake I did when originally adding `occur-hook' and it's now fixed). So, I've been thinking of adding an INTERACTIVE-P argument to `occur-rename-buffer' so it could be used in `occur-mode-hook' as is, instead of (add-hook 'occur-mode-hook #'(lambda () (occur-rename-buffer t))) The main reason is that then `occur-rename-buffer' can be added to `occur-mode-hook' via Customize, which is not an unreasonable thing to expect from any user who reads the `occur-rename-buffer' docstring. -- /L/e/k/t/u Index: lisp/replace.el =================================================================== RCS file: /cvsroot/emacs/emacs/lisp/replace.el,v retrieving revision 1.216 diff -r1.216 replace.el 924c924 < (defun occur-rename-buffer (&optional unique-p) --- > (defun occur-rename-buffer (&optional unique-p interactive-p) 931c931 < (interactive "P") --- > (interactive "P\np") 938c938 < unique-p))) --- > (or unique-p (not interactive-p))))) ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Changing occur-hook to occur-functions 2005-07-02 19:01 ` Juanma Barranquero @ 2005-07-03 20:42 ` Richard M. Stallman 2005-07-03 21:33 ` Juanma Barranquero 2005-07-04 4:02 ` Juanma Barranquero 2005-07-04 0:29 ` Juri Linkov 2005-07-04 0:29 ` Juri Linkov 2 siblings, 2 replies; 15+ messages in thread From: Richard M. Stallman @ 2005-07-03 20:42 UTC (permalink / raw) Cc: emacs-devel Please use diff -c to send patches. "Ordinary" diff lacks context and is therefore harder to understand. ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Changing occur-hook to occur-functions 2005-07-03 20:42 ` Richard M. Stallman @ 2005-07-03 21:33 ` Juanma Barranquero 2005-07-04 4:02 ` Juanma Barranquero 1 sibling, 0 replies; 15+ messages in thread From: Juanma Barranquero @ 2005-07-03 21:33 UTC (permalink / raw) Cc: emacs-devel On 7/3/05, Richard M. Stallman <rms@gnu.org> wrote: > Please use diff -c to send patches. My mistake. I was trying not to create "unified" patches and didn't realize these were "ordinary" instead of "context". -- /L/e/k/t/u ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Changing occur-hook to occur-functions 2005-07-03 20:42 ` Richard M. Stallman 2005-07-03 21:33 ` Juanma Barranquero @ 2005-07-04 4:02 ` Juanma Barranquero 2005-07-04 16:48 ` Richard M. Stallman 1 sibling, 1 reply; 15+ messages in thread From: Juanma Barranquero @ 2005-07-04 4:02 UTC (permalink / raw) Cc: emacs-devel On 7/3/05, Richard M. Stallman <rms@gnu.org> wrote: > Please use diff -c to send patches. "Ordinary" diff lacks context > and is therefore harder to understand. The patch I proposed was this one. -- /L/e/k/t/u Index: lisp/replace.el =================================================================== RCS file: /cvsroot/emacs/emacs/lisp/replace.el,v retrieving revision 1.217 diff -c -r1.217 replace.el *** lisp/replace.el 3 Jul 2005 22:49:00 -0000 1.217 --- lisp/replace.el 4 Jul 2005 03:59:50 -0000 *************** *** 921,941 **** (when current-prefix-arg (prefix-numeric-value current-prefix-arg)))) ! (defun occur-rename-buffer (&optional unique-p) "Rename the current *Occur* buffer to *Occur: original-buffer-name*. Here `original-buffer-name' is the buffer name were occur was originally run. When given the prefix argument, the renaming will not clobber the existing buffer(s) of that name, but use `generate-new-buffer-name' instead. You can add this to `occur-mode-hook' if you always want a separate *Occur* buffer for each buffer where you invoke `occur'." ! (interactive "P") (with-current-buffer (if (eq major-mode 'occur-mode) (current-buffer) (get-buffer "*Occur*")) (rename-buffer (concat "*Occur: " (mapconcat #'buffer-name (car (cddr occur-revert-arguments)) "/") "*") ! unique-p))) (defun occur (regexp &optional nlines) "Show all lines in the current buffer containing a match for REGEXP. --- 921,941 ---- (when current-prefix-arg (prefix-numeric-value current-prefix-arg)))) ! (defun occur-rename-buffer (&optional unique-p interactive-p) "Rename the current *Occur* buffer to *Occur: original-buffer-name*. Here `original-buffer-name' is the buffer name were occur was originally run. When given the prefix argument, the renaming will not clobber the existing buffer(s) of that name, but use `generate-new-buffer-name' instead. You can add this to `occur-mode-hook' if you always want a separate *Occur* buffer for each buffer where you invoke `occur'." ! (interactive "P\np") (with-current-buffer (if (eq major-mode 'occur-mode) (current-buffer) (get-buffer "*Occur*")) (rename-buffer (concat "*Occur: " (mapconcat #'buffer-name (car (cddr occur-revert-arguments)) "/") "*") ! (or unique-p (not interactive-p))))) (defun occur (regexp &optional nlines) "Show all lines in the current buffer containing a match for REGEXP. ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Changing occur-hook to occur-functions 2005-07-04 4:02 ` Juanma Barranquero @ 2005-07-04 16:48 ` Richard M. Stallman 2005-07-04 22:39 ` Juanma Barranquero 0 siblings, 1 reply; 15+ messages in thread From: Richard M. Stallman @ 2005-07-04 16:48 UTC (permalink / raw) Cc: emacs-devel The change you intend seems to be that occur-rename-buffer will always generate a unique name, when called interactively. The easy way to do that is just to change the interactive spec so that UNIQUE-P is always non-nil in an interactive call. Then update the doc string. ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Changing occur-hook to occur-functions 2005-07-04 16:48 ` Richard M. Stallman @ 2005-07-04 22:39 ` Juanma Barranquero 0 siblings, 0 replies; 15+ messages in thread From: Juanma Barranquero @ 2005-07-04 22:39 UTC (permalink / raw) Cc: emacs-devel > The change you intend seems to be that occur-rename-buffer will always > generate a unique name, when called interactively. Just the opposite. The function is designed to be executed interactively (it is bound to a key in the occur map), and I don't want to change its behavior. But its docstring suggests adding it to `occur-mode-hook', which is a reasonable thing to do if you always want a new name. In order for this to work, *without* changing its current behavior, I want to add an INTERACTIVE-P argument, as recommended in the docstring of `interactive-p', so I can detect that it is being executed directly with no arguments and no as an interactive call without arguments. That way, (add-hook 'occur-mode-hook 'occur-rename-bufferf) works, and so the user can simply add `occur-rename-buffer' to `occur-mode-hook' via the customize interface... -- /L/e/k/t/u ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Changing occur-hook to occur-functions 2005-07-02 19:01 ` Juanma Barranquero 2005-07-03 20:42 ` Richard M. Stallman @ 2005-07-04 0:29 ` Juri Linkov 2005-07-04 8:00 ` Juanma Barranquero 2005-07-04 0:29 ` Juri Linkov 2 siblings, 1 reply; 15+ messages in thread From: Juri Linkov @ 2005-07-04 0:29 UTC (permalink / raw) Cc: emacs-devel > While still on Occur, another little issue: the documentation of > `occur-rename-buffer' talks about adding it to `occur-mode-hook' (it > used to say to add it to `occur-hook', but that was a mistake I did > when originally adding `occur-hook' and it's now fixed). Why do you think it is a mistake? It doesn't work with `occur-mode-hook'. -- Juri Linkov http://www.jurta.org/emacs/ ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Changing occur-hook to occur-functions 2005-07-04 0:29 ` Juri Linkov @ 2005-07-04 8:00 ` Juanma Barranquero 2005-07-05 4:35 ` Richard M. Stallman 2005-07-05 5:27 ` Juri Linkov 0 siblings, 2 replies; 15+ messages in thread From: Juanma Barranquero @ 2005-07-04 8:00 UTC (permalink / raw) Cc: emacs-devel On 7/4/05, Juri Linkov <juri@jurta.org> wrote: > Why do you think it is a mistake? It doesn't work with `occur-mode-hook'. Neither does with `occur-hook'. You have to add (lambda () (occur-rename-buffer t)) to `occur-mode-hook' for it to work. That's why I proposed to add a new parameter INTERACTIVE-P to `occur-rename-buffer' so it can be just dropped onto the hook. Moreover, originally the `occur-rename-buffer' docstring talked about `occur-mode-hook'. I (mistakenly) changed it a while back when I renamed `occur-mode-hook' to `occur-hook' and moved it from `occur-mode' to `occur-1'. Almost immediately I realized `occur-mode-hook' was still needed and I re-added it, but I didn't change back the docstring for `occur-rename-buffer'. -- /L/e/k/t/u ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Changing occur-hook to occur-functions 2005-07-04 8:00 ` Juanma Barranquero @ 2005-07-05 4:35 ` Richard M. Stallman 2005-07-05 8:32 ` Juanma Barranquero 2005-07-05 5:27 ` Juri Linkov 1 sibling, 1 reply; 15+ messages in thread From: Richard M. Stallman @ 2005-07-05 4:35 UTC (permalink / raw) Cc: juri, emacs-devel to `occur-mode-hook' for it to work. That's why I proposed to add a new parameter INTERACTIVE-P to `occur-rename-buffer' so it can be just dropped onto the hook. I see I misunderstood the diff when I looked at it. I am too sleepy. ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Changing occur-hook to occur-functions 2005-07-05 4:35 ` Richard M. Stallman @ 2005-07-05 8:32 ` Juanma Barranquero 2005-07-05 9:29 ` Lute Kamstra 0 siblings, 1 reply; 15+ messages in thread From: Juanma Barranquero @ 2005-07-05 8:32 UTC (permalink / raw) Cc: emacs-devel > I see I misunderstood the diff when I looked at it. > I am too sleepy. That last sentence practically summarizes my last two or three months. -- /L/e/k/t/u ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Changing occur-hook to occur-functions 2005-07-05 8:32 ` Juanma Barranquero @ 2005-07-05 9:29 ` Lute Kamstra 0 siblings, 0 replies; 15+ messages in thread From: Lute Kamstra @ 2005-07-05 9:29 UTC (permalink / raw) Cc: rms, emacs-devel Juanma Barranquero <lekktu@gmail.com> writes: >> I am too sleepy. > > That last sentence practically summarizes my last two or three months. My partner is an MD. Whenever I suffer from the symptoms you describe, she advises me to go to bed and sleep. Try it, it works for me. Lute. ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Changing occur-hook to occur-functions 2005-07-04 8:00 ` Juanma Barranquero 2005-07-05 4:35 ` Richard M. Stallman @ 2005-07-05 5:27 ` Juri Linkov 2005-07-05 10:15 ` Juanma Barranquero 1 sibling, 1 reply; 15+ messages in thread From: Juri Linkov @ 2005-07-05 5:27 UTC (permalink / raw) Cc: emacs-devel >> Why do you think it is a mistake? It doesn't work with `occur-mode-hook'. > > Neither does with `occur-hook'. You have to add > > (lambda () (occur-rename-buffer t)) That's exactly what I tried. With the latest CVS state (add-hook 'occur-hook (lambda () (occur-rename-buffer t))) renames the *Occur* buffer to `*Occur: original-buffer-name*', but (add-hook 'occur-mode-hook (lambda () (occur-rename-buffer t))) produces a name with empty original-buffer-name (i.e. just `*Occur: *'), because `occur-1' sets the value of `occur-revert-arguments' after running `occur-mode-hook', but before `occur-hook'. > to `occur-mode-hook' for it to work. That's why I proposed to add a > new parameter INTERACTIVE-P to `occur-rename-buffer' so it can be just > dropped onto the hook. This would be good, but without adding original-buffer-name to the buffer name, to produce a unique buffer name, the user can simply put (add-hook 'occur-mode-hook 'rename-uniquely) -- Juri Linkov http://www.jurta.org/emacs/ ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Changing occur-hook to occur-functions 2005-07-05 5:27 ` Juri Linkov @ 2005-07-05 10:15 ` Juanma Barranquero 0 siblings, 0 replies; 15+ messages in thread From: Juanma Barranquero @ 2005-07-05 10:15 UTC (permalink / raw) Cc: emacs-devel On 7/5/05, Juri Linkov <juri@jurta.org> wrote: > That's exactly what I tried. With the latest CVS state > > (add-hook 'occur-hook (lambda () (occur-rename-buffer t))) > > renames the *Occur* buffer to `*Occur: original-buffer-name*', but > > (add-hook 'occur-mode-hook (lambda () (occur-rename-buffer t))) > > produces a name with empty original-buffer-name (i.e. just `*Occur: *'), > because `occur-1' sets the value of `occur-revert-arguments' > after running `occur-mode-hook', but before `occur-hook'. Ah, very funny. I was right that originally changing the docstring was a mistake (I know for sure, the mistake was mine :) And you're right, as it now stands, it'd be better to advise the user to use `occur-hook' and not `occur-mode-hook'. > This would be good, but without adding original-buffer-name to the > buffer name, to produce a unique buffer name, the user can simply put > > (add-hook 'occur-mode-hook 'rename-uniquely) Sure. But we really want the original buffer name. So the right fix is to modify `occur-rename-buffer' to do the right thing in a hook, and change back its docstring to recommend using `occur-hook'. -- /L/e/k/t/u Index: lisp/replace.el =================================================================== RCS file: /cvsroot/emacs/emacs/lisp/replace.el,v retrieving revision 1.218 diff -c -r1.218 replace.el *** lisp/replace.el 4 Jul 2005 23:08:57 -0000 1.218 --- lisp/replace.el 5 Jul 2005 10:10:52 -0000 *************** *** 921,941 **** (when current-prefix-arg (prefix-numeric-value current-prefix-arg)))) ! (defun occur-rename-buffer (&optional unique-p) "Rename the current *Occur* buffer to *Occur: original-buffer-name*. ! Here `original-buffer-name' is the buffer name were occur was originally run. ! When given the prefix argument, the renaming will not clobber the existing ! buffer(s) of that name, but use `generate-new-buffer-name' instead. ! You can add this to `occur-mode-hook' if you always want a separate *Occur* ! buffer for each buffer where you invoke `occur'." ! (interactive "P") (with-current-buffer (if (eq major-mode 'occur-mode) (current-buffer) (get-buffer "*Occur*")) (rename-buffer (concat "*Occur: " (mapconcat #'buffer-name (car (cddr occur-revert-arguments)) "/") "*") ! unique-p))) (defun occur (regexp &optional nlines) "Show all lines in the current buffer containing a match for REGEXP. --- 921,942 ---- (when current-prefix-arg (prefix-numeric-value current-prefix-arg)))) ! (defun occur-rename-buffer (&optional unique-p interactive-p) "Rename the current *Occur* buffer to *Occur: original-buffer-name*. ! Here `original-buffer-name' is the buffer name were Occur was originally run. ! When given the prefix argument, or called non-interactively, the renaming ! will not clobber the existing buffer(s) of that name, but use ! `generate-new-buffer-name' instead. You can add this to `occur-hook' ! if you always want a separate *Occur* buffer for each buffer where you ! invoke `occur'." ! (interactive "P\np") (with-current-buffer (if (eq major-mode 'occur-mode) (current-buffer) (get-buffer "*Occur*")) (rename-buffer (concat "*Occur: " (mapconcat #'buffer-name (car (cddr occur-revert-arguments)) "/") "*") ! (or unique-p (not interactive-p))))) (defun occur (regexp &optional nlines) "Show all lines in the current buffer containing a match for REGEXP. ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Changing occur-hook to occur-functions 2005-07-02 19:01 ` Juanma Barranquero 2005-07-03 20:42 ` Richard M. Stallman 2005-07-04 0:29 ` Juri Linkov @ 2005-07-04 0:29 ` Juri Linkov 2 siblings, 0 replies; 15+ messages in thread From: Juri Linkov @ 2005-07-04 0:29 UTC (permalink / raw) Cc: emacs-devel BTW, the docstrings of `compilation-mode-hook' doesn't match the code. I suppose that the code is right and that only docstrings need to be fixed: Index: lisp/progmodes/compile.el =================================================================== RCS file: /cvsroot/emacs/emacs/lisp/progmodes/compile.el,v retrieving revision 1.363 diff -u -r1.363 compile.el --- lisp/progmodes/compile.el 28 Jun 2005 18:57:00 -0000 1.363 +++ lisp/progmodes/compile.el 4 Jul 2005 00:29:16 -0000 @@ -78,7 +78,7 @@ ;;;###autoload (defcustom compilation-mode-hook nil - "*List of hook functions run by `compilation-mode' (see `run-hooks')." + "*List of hook functions run by `compilation-mode' (see `run-mode-hooks')." :type 'hook :group 'compilation) @@ -1213,7 +1213,7 @@ move point to the error message line and type \\[compile-goto-error]. To kill the compilation, type \\[kill-compilation]. -Runs `compilation-mode-hook' with `run-hooks' (which see). +Runs `compilation-mode-hook' with `run-mode-hooks' (which see). \\{compilation-mode-map}" (interactive) -- Juri Linkov http://www.jurta.org/emacs/ ^ permalink raw reply [flat|nested] 15+ messages in thread
end of thread, other threads:[~2005-07-05 10:15 UTC | newest] Thread overview: 15+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2005-07-02 18:40 Changing occur-hook to occur-functions Juanma Barranquero 2005-07-02 19:01 ` Juanma Barranquero 2005-07-03 20:42 ` Richard M. Stallman 2005-07-03 21:33 ` Juanma Barranquero 2005-07-04 4:02 ` Juanma Barranquero 2005-07-04 16:48 ` Richard M. Stallman 2005-07-04 22:39 ` Juanma Barranquero 2005-07-04 0:29 ` Juri Linkov 2005-07-04 8:00 ` Juanma Barranquero 2005-07-05 4:35 ` Richard M. Stallman 2005-07-05 8:32 ` Juanma Barranquero 2005-07-05 9:29 ` Lute Kamstra 2005-07-05 5:27 ` Juri Linkov 2005-07-05 10:15 ` Juanma Barranquero 2005-07-04 0:29 ` Juri Linkov
Code repositories for project(s) associated with this external index https://git.savannah.gnu.org/cgit/emacs.git https://git.savannah.gnu.org/cgit/emacs/org-mode.git This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.