+2003-05-09 Stefan Monnier <monnier@cs.yale.edu>
+
+ * uniquify.el: Use the original buffer-name as `base' in place of the
+ nondirectory part of the file name.
+ (uniquify-rationalize-file-buffer-names):
+ Split the `newbuffile' arg into `base' and `dirname'.
+ Reuse old uniquify-items to avoid recomputing their base&dirname.
+ (uniquify-buffer-file-name): Only return the directory part.
+ (uniquify-rerationalize-w/o-cb): Don't bother reseting proposed names.
+ (rename-buffer): Use the `newname' arg as base.
+ (create-file-buffer): Split the file name into base and dirname.
+
2003-05-09 Jesper Harder <harder@ifa.au.dk> (tiny change)
* mail/smtpmail.el (smtpmail-send-queued-mail): Don't use kill-line.
* language/ind-util.el (indian-2-column-to-ucs-region): Fix for
the case of replacing multibyte characters.
-2003-04-09 Stefan Monnier <monnier@cs.yale.edu>
-
- * textmodes/bibtex.el: Update copyright and Author list.
- Don't require `compile' since it seems unnecessary.
- (bibtex-version): Remove.
- (bibtex-sort-ignore-string-entries, bibtex-maintain-sorted-entries)
- (bibtex-field-name-for-parsing): Don't make auto-buffer-local.
- (bibtex-comment-start): Don't include the space.
- (zmacs-regions, reporter-prompt-for-summary-p):
- Declare to quieten the byte-compiler.
- (bibtex-reference-key, bibtex-mode-syntax-table): Remove =
- because it can't be part of a string's key.
- (bibtex-parse-field-name): Use prog1.
- (bibtex-font-lock-syntactic-keywords): New var.
- (bibtex-font-lock-keywords): Remove the entry for @Comment.
- (bibtex-search-entry): Simplify.
- (bibtex-empty-re): New var.
- (bibtex-format-entry): Slightly restructure some loops to avoid code
- duplication. Use looking-at rather than `substring + string-match'.
- Use bibtex-empty-re (which removes unnecessary \(..\) in regexps).
- Remove now unused end-name. Use bibtex-find-crossref.
- Don't downcase since case-fold-search is t.
- (bibtex-autokey-get-yearfield): Use bibtex-find-crossref.
- (bibtex-parse-keys): Use unless and push.
- Parse even if bibtex-maintain-sorted-entries is nil.
- (bibtex-complete): Use push. Don't sort completions.
- (bibtex-mode): Use push. Update comment-start-skip.
- Improve defun-prompt-regexp and outline-regexp.
- Add bibtex-font-lock-syntactic-keywords to font-lock-defaults.
- (bibtex-end-of-entry): Remove unused \(...\).
- (bibtex-sort-key): New fun.
- (bibtex-sort-buffer, bibtex-validate): Use it.
- (bibtex-find-crossref): New fun.
- (bibtex-validate): Use push & dolist; remove \(...\).
- (bibtex-clean-entry): Use unless and friends.
- Don't add the key to the list if the list hasn't been built yet.
- (bibtex-fill-entry): Remove unused begin-name and end-name.
- (bibtex-reformat): Kill local var instead of setting it to nil.
- (bibtex-convert-alien): Use deactivate-mark rather than the
- non-existent bibtex-mark-active variable.
- (bibtex-String): Simplify.
-
2003-04-09 Richard M. Stallman <rms@gnu.org>
* files.el (file-chase-links): Fix previous change.
;;; Main entry point.
-(defun uniquify-rationalize-file-buffer-names (newbuffile newbuf)
+(defun uniquify-rationalize-file-buffer-names (base dirname newbuf)
"Make file buffer names unique by adding segments from file name.
If `uniquify-min-dir-content' > 0, always pulls that many
file name elements.
Arguments NEWBUFFILE and NEWBUF cause only a subset of buffers to be renamed."
(interactive)
- (if (null newbuffile)
+ (if (null dirname)
(with-current-buffer newbuf (setq uniquify-managed nil))
- (setq newbuffile (expand-file-name (directory-file-name newbuffile)))
- (let ((fix-list nil)
- (base (file-name-nondirectory newbuffile)))
+ (setq dirname (expand-file-name (directory-file-name dirname)))
+ (let ((fix-list (list (uniquify-make-item base dirname newbuf)))
+ items)
(dolist (buffer (buffer-list))
- (let ((bufname (buffer-name buffer))
- bfn)
- (when (and (not (and uniquify-ignore-buffers-re
- (string-match uniquify-ignore-buffers-re
- bufname)))
- ;; Only try to rename buffers we actually manage.
- (or (buffer-local-value 'uniquify-managed buffer)
- (eq buffer newbuf))
- (setq bfn (if (eq buffer newbuf) newbuffile
- (uniquify-buffer-file-name buffer)))
- (equal (file-name-nondirectory bfn) base))
- (when (setq bfn (file-name-directory bfn)) ;Strip off the `base'.
- (setq bfn (directory-file-name bfn))) ;Strip trailing slash.
- (push (uniquify-make-item base bfn buffer)
- fix-list))))
+ (when (and (not (and uniquify-ignore-buffers-re
+ (string-match uniquify-ignore-buffers-re
+ (buffer-name buffer))))
+ ;; Only try to rename buffers we actually manage.
+ (setq items (buffer-local-value 'uniquify-managed buffer))
+ (equal base (uniquify-item-base (car items)))
+ ;; Don't re-add stuff we already have. Actually this
+ ;; whole `and' test should only match at most once.
+ (not (memq (car items) fix-list)))
+ (setq fix-list (append fix-list items))))
;; selects buffers whose names may need changing, and others that
;; may conflict, then bring conflicting names together
(uniquify-rationalize fix-list))))
;; uniquify's version of buffer-file-name; result never contains trailing slash
(defun uniquify-buffer-file-name (buffer)
- "Return name of file BUFFER is visiting, or nil if none.
+ "Return name of directory, file BUFFER is visiting, or nil if none.
Works on ordinary file-visiting buffers and buffers whose mode is mentioned
in `uniquify-list-buffers-directory-modes', otherwise returns nil."
- (or (buffer-file-name buffer)
- (with-current-buffer buffer
- (if (memq major-mode uniquify-list-buffers-directory-modes)
- (and list-buffers-directory
- (directory-file-name list-buffers-directory))))))
+ (with-current-buffer buffer
+ (let ((filename
+ (or buffer-file-name
+ (if (memq major-mode uniquify-list-buffers-directory-modes)
+ list-buffers-directory))))
+ (when filename
+ (file-name-directory (expand-file-name (directory-file-name filename)))))))
(defun uniquify-rerationalize-w/o-cb (fix-list)
"Re-rationalize the buffers in FIX-LIST, but ignoring current-buffer."
(dolist (item fix-list)
(let ((buf (uniquify-item-buffer item)))
(unless (or (eq buf (current-buffer)) (not (buffer-live-p buf)))
- ;; Reset the proposed names.
- (setf (uniquify-item-proposed item)
- (uniquify-get-proposed-name (uniquify-item-base item)
- (uniquify-item-dirname item)))
(push item new-fix-list))))
(when new-fix-list
(uniquify-rationalize new-fix-list))))
(when uniquify-buffer-name-style
;; Rerationalize w.r.t the new name.
(uniquify-rationalize-file-buffer-names
- (uniquify-buffer-file-name (current-buffer)) (current-buffer))
+ (ad-get-arg 0)
+ (uniquify-buffer-file-name (current-buffer))
+ (current-buffer))
(setq ad-return-value (buffer-name (current-buffer))))))
(defadvice create-file-buffer (after create-file-buffer-uniquify activate)
"Uniquify buffer names with parts of directory name."
(if uniquify-buffer-name-style
- (uniquify-rationalize-file-buffer-names (ad-get-arg 0) ad-return-value)))
+ (let ((filename (expand-file-name (directory-file-name (ad-get-arg 0)))))
+ (uniquify-rationalize-file-buffer-names
+ (file-name-nondirectory filename)
+ (file-name-directory filename) ad-return-value))))
;; Buffer deletion
;; Rerationalize after a buffer is killed, to reduce coinciding buffer names.