help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Redundant left-over buffer after rename-buffer


From: Thorsten Jolitz
Subject: Redundant left-over buffer after rename-buffer
Date: Sat, 23 Feb 2013 12:55:34 +0100
User-agent: Gnus/5.130002 (Ma Gnus v0.2) Emacs/24.2 (gnu/linux)

Hi List, 

I want to rename *Occur* buffers following the advice given in
`occur-rename-buffer' from `replace.el', with slightly modified and
renamed code:

,-------------------------------------------------------------------------------
| ;; slightly modified `occur-rename-buffer' from `replace.el'
| (defun navi-rename-buffer (&optional unique-p)
|   "Rename the current *Occur* buffer to *Navi: original-buffer-name*.
| Here `original-buffer-name' is the buffer name where 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-hook' if you always want a separate *Occur* buffer for
| each buffer where you invoke `occur'."
|   (with-current-buffer
|       (if (eq major-mode 'occur-mode) (current-buffer) (get-buffer "*Occur*"))
|     (rename-buffer (concat "*Navi: "
|                            (mapconcat #'buffer-name
|                                       (car (cddr occur-revert-arguments)) "/")
|                            "*")
|                    unique-p)))
| 
| (add-to-list 'occur-hook 'navi-rename-buffer)
`-------------------------------------------------------------------------------

However, while the renaming works and the search results from occur are
presented in a buffer called *Navi: original-buffer-name*, an empty
*Occur* buffer in fundamental mood remains as a (redundant) left-over. 

  ,-------------------------------------
  | (kill-buffer (get-buffer "*Occur*"))
  `-------------------------------------

If I try to add the above function call as last statement into the
defun, I'm told that I'm trying to kill a non-existing buffer. 

How can I avoid (or get rid of) the left-over *Occur* buffer in
fundamental mode after the renaming operation?

-- 
cheers,
Thorsten





reply via email to

[Prev in Thread] Current Thread [Next in Thread]