aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2013-03-25 23:38:18 -0400
committerStefan Monnier2013-03-25 23:38:18 -0400
commit69b2c07eaf592dee54ccd9bdb5f38dce88d1f221 (patch)
tree194af7026efb99e9586cf4135615da69e3fc3597
parent08bb5ee241848b0bd9297274f1e76aaaae3245de (diff)
downloademacs-69b2c07eaf592dee54ccd9bdb5f38dce88d1f221.tar.gz
emacs-69b2c07eaf592dee54ccd9bdb5f38dce88d1f221.zip
* lisp/desktop.el (desktop--v2s): Rename from desktop-internal-v2s.
Change return value to be a sexp. Delay `get-buffer' to after restoring the desktop. Fixes: debbugs:13951
-rw-r--r--lisp/ChangeLog6
-rw-r--r--lisp/desktop.el106
2 files changed, 53 insertions, 59 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 3f7e3efa424..e86bc7f0a96 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,9 @@
12013-03-26 Stefan Monnier <monnier@iro.umontreal.ca>
2
3 * desktop.el (desktop--v2s): Rename from desktop-internal-v2s.
4 Change return value to be a sexp. Delay `get-buffer' to after
5 restoring the desktop (bug#13951).
6
12013-03-26 Leo Liu <sdl.web@gmail.com> 72013-03-26 Leo Liu <sdl.web@gmail.com>
2 8
3 * register.el: Move semantic tag handling back to 9 * register.el: Move semantic tag handling back to
diff --git a/lisp/desktop.el b/lisp/desktop.el
index 1151bd434bc..9c95f597fff 100644
--- a/lisp/desktop.el
+++ b/lisp/desktop.el
@@ -697,83 +697,69 @@ is nil, ask the user where to save the desktop."
697 ll))) 697 ll)))
698 698
699;; ---------------------------------------------------------------------------- 699;; ----------------------------------------------------------------------------
700(defun desktop-internal-v2s (value) 700(defun desktop--v2s (value)
701 "Convert VALUE to a pair (QUOTE . TXT); (eval (read TXT)) gives VALUE. 701 "Convert VALUE to a pair (QUOTE . SEXP); (eval SEXP) gives VALUE.
702TXT is a string that when read and evaluated yields VALUE. 702SEXP is an sexp that when evaluated yields VALUE.
703QUOTE may be `may' (value may be quoted), 703QUOTE may be `may' (value may be quoted),
704`must' (value must be quoted), or nil (value must not be quoted)." 704`must' (value must be quoted), or nil (value must not be quoted)."
705 (cond 705 (cond
706 ((or (numberp value) (null value) (eq t value) (keywordp value)) 706 ((or (numberp value) (null value) (eq t value) (keywordp value))
707 (cons 'may (prin1-to-string value))) 707 (cons 'may value))
708 ((stringp value) 708 ((stringp value)
709 (let ((copy (copy-sequence value))) 709 (let ((copy (copy-sequence value)))
710 (set-text-properties 0 (length copy) nil copy) 710 (set-text-properties 0 (length copy) nil copy)
711 ;; Get rid of text properties because we cannot read them 711 ;; Get rid of text properties because we cannot read them.
712 (cons 'may (prin1-to-string copy)))) 712 (cons 'may copy)))
713 ((symbolp value) 713 ((symbolp value)
714 (cons 'must (prin1-to-string value))) 714 (cons 'must value))
715 ((vectorp value) 715 ((vectorp value)
716 (let* ((special nil) 716 (let* ((pass1 (mapcar #'desktop--v2s value))
717 (pass1 (mapcar 717 (special (assq nil pass1)))
718 (lambda (el)
719 (let ((res (desktop-internal-v2s el)))
720 (if (null (car res))
721 (setq special t))
722 res))
723 value)))
724 (if special 718 (if special
725 (cons nil (concat "(vector " 719 (cons nil `(vector
726 (mapconcat (lambda (el) 720 ,@(mapcar (lambda (el)
727 (if (eq (car el) 'must) 721 (if (eq (car el) 'must)
728 (concat "'" (cdr el)) 722 `',(cdr el) (cdr el)))
729 (cdr el))) 723 pass1)))
730 pass1 724 (cons 'may `[,@(mapcar #'cdr pass1)]))))
731 " ")
732 ")"))
733 (cons 'may (concat "[" (mapconcat 'cdr pass1 " ") "]")))))
734 ((consp value) 725 ((consp value)
735 (let ((p value) 726 (let ((p value)
736 newlist 727 newlist
737 use-list* 728 use-list*
738 anynil) 729 anynil)
739 (while (consp p) 730 (while (consp p)
740 (let ((q.txt (desktop-internal-v2s (car p)))) 731 (let ((q.sexp (desktop--v2s (car p))))
741 (or anynil (setq anynil (null (car q.txt)))) 732 (push q.sexp newlist))
742 (setq newlist (cons q.txt newlist)))
743 (setq p (cdr p))) 733 (setq p (cdr p)))
744 (if p 734 (when p
745 (let ((last (desktop-internal-v2s p))) 735 (let ((last (desktop--v2s p)))
746 (or anynil (setq anynil (null (car last)))) 736 (setq use-list* t)
747 (or anynil 737 (push last newlist)))
748 (setq newlist (cons '(must . ".") newlist))) 738 (if (assq nil newlist)
749 (setq use-list* t)
750 (setq newlist (cons last newlist))))
751 (setq newlist (nreverse newlist))
752 (if anynil
753 (cons nil 739 (cons nil
754 (concat (if use-list* "(desktop-list* " "(list ") 740 `(,(if use-list* 'desktop-list* 'list)
755 (mapconcat (lambda (el) 741 ,@(mapcar (lambda (el)
756 (if (eq (car el) 'must) 742 (if (eq (car el) 'must)
757 (concat "'" (cdr el)) 743 `',(cdr el) (cdr el)))
758 (cdr el))) 744 (nreverse newlist))))
759 newlist
760 " ")
761 ")"))
762 (cons 'must 745 (cons 'must
763 (concat "(" (mapconcat 'cdr newlist " ") ")"))))) 746 `(,@(mapcar #'cdr
747 (nreverse (if use-list* (cdr newlist) newlist)))
748 ,@(if use-list* (cdar newlist)))))))
764 ((subrp value) 749 ((subrp value)
765 (cons nil (concat "(symbol-function '" 750 (cons nil `(symbol-function
766 (substring (prin1-to-string value) 7 -1) 751 ',(intern-soft (substring (prin1-to-string value) 7 -1)))))
767 ")")))
768 ((markerp value) 752 ((markerp value)
769 (let ((pos (prin1-to-string (marker-position value))) 753 (let ((pos (marker-position value))
770 (buf (prin1-to-string (buffer-name (marker-buffer value))))) 754 (buf (buffer-name (marker-buffer value))))
771 (cons nil (concat "(let ((mk (make-marker)))" 755 (cons nil
772 " (add-hook 'desktop-delay-hook" 756 `(let ((mk (make-marker)))
773 " (list 'lambda '() (list 'set-marker mk " 757 (add-hook 'desktop-delay-hook
774 pos " (get-buffer " buf ")))) mk)")))) 758 `(lambda ()
775 (t ; save as text 759 (set-marker ,mk ,,pos (get-buffer ,,buf))))
776 (cons 'may "\"Unprintable entity\"")))) 760 mk))))
761 (t ; Save as text.
762 (cons 'may "Unprintable entity"))))
777 763
778;; ---------------------------------------------------------------------------- 764;; ----------------------------------------------------------------------------
779(defun desktop-value-to-string (value) 765(defun desktop-value-to-string (value)
@@ -781,9 +767,11 @@ QUOTE may be `may' (value may be quoted),
781Not all types of values are supported." 767Not all types of values are supported."
782 (let* ((print-escape-newlines t) 768 (let* ((print-escape-newlines t)
783 (float-output-format nil) 769 (float-output-format nil)
784 (quote.txt (desktop-internal-v2s value)) 770 (quote.sexp (desktop--v2s value))
785 (quote (car quote.txt)) 771 (quote (car quote.sexp))
786 (txt (cdr quote.txt))) 772 (txt
773 (let ((print-quoted t))
774 (prin1-to-string (cdr quote.sexp)))))
787 (if (eq quote 'must) 775 (if (eq quote 'must)
788 (concat "'" txt) 776 (concat "'" txt)
789 txt))) 777 txt)))