From: Juanma Barranquero <lekktu@gmail.com>
Cc: emacs-devel@gnu.org
Subject: Re: Changing occur-hook to occur-functions
Date: Tue, 5 Jul 2005 12:15:03 +0200 [thread overview]
Message-ID: <f7ccd24b050705031579d1db5c@mail.gmail.com> (raw)
In-Reply-To: <87oe9hnah4.fsf@jurta.org>
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.
next prev parent reply other threads:[~2005-07-05 10:15 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
2005-07-04 0:29 ` Juri Linkov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=f7ccd24b050705031579d1db5c@mail.gmail.com \
--to=lekktu@gmail.com \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.