unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* (source) Anything like this exist already? (buffer name intelligence)
@ 2008-01-11 19:01 Aaron Maxwell
  2008-01-11 19:48 ` Juanma Barranquero
       [not found] ` <mailman.6054.1200080936.18990.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 3+ messages in thread
From: Aaron Maxwell @ 2008-01-11 19:01 UTC (permalink / raw)
  To: help-gnu-emacs

Here's the defun I refered to in my post a moment ago:
; Better handle similar buffer names
(defun extend-buffer-name (arg)
  "Extend the current buffer's name according to to its full file path.
With prefix arg, extend by N levels.  Default is one level."
  (interactive "P")
  (let ((path (buffer-file-name))
        (sep "/")
        (n (prefix-numeric-value arg)))
    (cond
     ((or (null path)
          (equal "" path))
      path)
     (t (let ((parts (reverse (split-string path sep))))
          (defun extend-once (sofar parts n)
            (cond
             ((or (< n 1)
                  (null parts))
              sofar)
             (t (extend-once (concatenate 'string (car parts) sep sofar)
                        (cdr parts)
                        (1- n)))))
          (rename-buffer (extend-once (car parts) (cdr parts) n)))))))



-- 
Aaron Maxwell
http://redsymbol.net

Business Owners and Self-Employed:  You're NOT Alone!
The Business Butler - http://businessbutler.us

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2008-01-11 20:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-01-11 19:01 (source) Anything like this exist already? (buffer name intelligence) Aaron Maxwell
2008-01-11 19:48 ` Juanma Barranquero
     [not found] ` <mailman.6054.1200080936.18990.help-gnu-emacs@gnu.org>
2008-01-11 20:10   ` Aaron Maxwell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).