emacs-devel
[Top][All Lists]
Advanced

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

Re: 22.1.90; desktop-save throws (error "No buffer named <uniquified buf


From: Juanma Barranquero
Subject: Re: 22.1.90; desktop-save throws (error "No buffer named <uniquified buffername>")
Date: Tue, 12 Feb 2008 01:44:13 +0100

On Feb 8, 2008 10:17 PM, Stefan Monnier <address@hidden> wrote:

> Actually, any use of the "base name" will be uniquify-specific as well,
> so I'll still say "Yuck!".

Well, I'm trying to fix a problem derived of the interaction of
uniquify and desktop, so using uniquify-specific info seems
unavoidable.

> Indeed for uniquified buffers, you should only [need to] save the
> base-name to disk, so there's no need to change the disk representation
> of your data.

The "base name" and the buffer name are two different pieces of info;
even if no uniquify is present, it would be perhaps interesting to
know (and save) whether "my-buffer<2>" is called so by user fiat or
via rename-buffer's UNIQUE argument; but that is not needed right now.

Anyway. Does this version lessen your yucky factor somewhat?

             Juanma


Index: lisp/uniquify.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/uniquify.el,v
retrieving revision 1.62.2.7
diff -u -2 -r1.62.2.7 uniquify.el
--- lisp/uniquify.el    7 Jan 2008 02:44:10 -0000       1.62.2.7
+++ lisp/uniquify.el    12 Feb 2008 00:10:32 -0000
@@ -190,4 +190,10 @@
 (put 'uniquify-managed 'permanent-local t)

+;; Used in desktop.el to save the non-uniquified buffer name
+(defun uniquify-buffer-base-name ()
+  "Return the base name of the current buffer."
+  (and (bound-and-true-p uniquify-managed)
+       (uniquify-item-base (car uniquify-managed))))
+
 ;;; Main entry point.

Index: lisp/desktop.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/desktop.el,v
retrieving revision 1.108.2.6
diff -u -2 -r1.108.2.6 desktop.el
--- lisp/desktop.el     7 Jan 2008 02:44:57 -0000       1.108.2.6
+++ lisp/desktop.el     12 Feb 2008 00:14:02 -0000
@@ -136,6 +136,4 @@
 ;;; Code:

-(defvar uniquify-managed)
-
 (defvar desktop-file-version "206"
   "Version number of desktop file format.
@@ -654,9 +652,9 @@
   (set-buffer buffer)
   (list
+   ;; base name of the buffer; replaces the buffer name if managed by uniquify
+   (and (fboundp 'uniquify-buffer-base-name) (uniquify-buffer-base-name))
    ;; basic information
    (desktop-file-name (buffer-file-name) desktop-dirname)
-   (if (bound-and-true-p uniquify-managed)
-       (uniquify-item-base (car uniquify-managed))
-     (buffer-name))
+   (buffer-name)
    major-mode
    ;; minor modes
@@ -887,5 +885,5 @@
          (insert "\n;; Buffer section -- buffers listed in same order as in
buffer list:\n")
          (dolist (l (mapcar 'desktop-buffer-info (buffer-list)))
-           (when (apply 'desktop-save-buffer-p l)
+           (when (apply 'desktop-save-buffer-p (cdr l))
              (insert "("
                      (if (or (not (integerp eager))
@@ -897,4 +895,7 @@
                      " "
                      desktop-file-version)
+             (let ((base (pop l)))
+               ;; If the base name is non-nil, we substitute it for the buffer 
name
+               (when base (setcar (nthcdr 1 l) base)))
              (dolist (e l)
                (insert "\n  " (desktop-value-to-string e)))




reply via email to

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