Add desktop support for restoring vc-dir buffers (bug#10606)
* lisp/vc/vc-dir.el (vc-dir-mode): Autoload it (for desktop restore). Set buffer-local value of desktop-save-buffer. (vc-dir-desktop-buffer-misc-data, vc-dir-restore-desktop-buffer): New functions. (desktop-buffer-mode-handlers): Add vc-dir-mode entry. * lisp/desktop.el (desktop-save-buffer-p): Treat vc-dir like dired.
This commit is contained in:
parent
e9df8f871d
commit
4ad900d993
3 changed files with 38 additions and 1 deletions
|
@ -1,5 +1,13 @@
|
||||||
2012-11-29 Glenn Morris <rgm@gnu.org>
|
2012-11-29 Glenn Morris <rgm@gnu.org>
|
||||||
|
|
||||||
|
Add desktop support for restoring vc-dir buffers. (Bug#10606)
|
||||||
|
* vc/vc-dir.el (vc-dir-mode): Autoload it (for desktop restore).
|
||||||
|
Set buffer-local value of desktop-save-buffer.
|
||||||
|
(vc-dir-desktop-buffer-misc-data, vc-dir-restore-desktop-buffer):
|
||||||
|
New functions.
|
||||||
|
(desktop-buffer-mode-handlers): Add vc-dir-mode entry.
|
||||||
|
* desktop.el (desktop-save-buffer-p): Treat vc-dir like dired.
|
||||||
|
|
||||||
* files.el (inhibit-local-variables-ignore-case): New. (Bug#10610)
|
* files.el (inhibit-local-variables-ignore-case): New. (Bug#10610)
|
||||||
(inhibit-local-variables-p): Use inhibit-local-variables-ignore-case.
|
(inhibit-local-variables-p): Use inhibit-local-variables-ignore-case.
|
||||||
Doc fix.
|
Doc fix.
|
||||||
|
|
|
@ -825,7 +825,7 @@ MODE is the major mode.
|
||||||
(or (and filename
|
(or (and filename
|
||||||
(stringp desktop-files-not-to-save)
|
(stringp desktop-files-not-to-save)
|
||||||
(not (string-match desktop-files-not-to-save filename)))
|
(not (string-match desktop-files-not-to-save filename)))
|
||||||
(and (eq mode 'dired-mode)
|
(and (memq mode '(dired-mode vc-dir-mode))
|
||||||
(with-current-buffer bufname
|
(with-current-buffer bufname
|
||||||
(not (setq dired-skip
|
(not (setq dired-skip
|
||||||
(string-match desktop-files-not-to-save
|
(string-match desktop-files-not-to-save
|
||||||
|
|
|
@ -930,6 +930,8 @@ If it is a file, return the corresponding cons for the file itself."
|
||||||
|
|
||||||
(defvar use-vc-backend) ;; dynamically bound
|
(defvar use-vc-backend) ;; dynamically bound
|
||||||
|
|
||||||
|
;; Autoload cookie needed by desktop.el.
|
||||||
|
;;;###autoload
|
||||||
(define-derived-mode vc-dir-mode special-mode "VC dir"
|
(define-derived-mode vc-dir-mode special-mode "VC dir"
|
||||||
"Major mode for VC directory buffers.
|
"Major mode for VC directory buffers.
|
||||||
Marking/Unmarking key bindings and actions:
|
Marking/Unmarking key bindings and actions:
|
||||||
|
@ -967,6 +969,8 @@ the *vc-dir* buffer.
|
||||||
|
|
||||||
\\{vc-dir-mode-map}"
|
\\{vc-dir-mode-map}"
|
||||||
(set (make-local-variable 'vc-dir-backend) use-vc-backend)
|
(set (make-local-variable 'vc-dir-backend) use-vc-backend)
|
||||||
|
(set (make-local-variable 'desktop-save-buffer)
|
||||||
|
'vc-dir-desktop-buffer-misc-data)
|
||||||
(setq buffer-read-only t)
|
(setq buffer-read-only t)
|
||||||
(when (boundp 'tool-bar-map)
|
(when (boundp 'tool-bar-map)
|
||||||
(set (make-local-variable 'tool-bar-map) vc-dir-tool-bar-map))
|
(set (make-local-variable 'tool-bar-map) vc-dir-tool-bar-map))
|
||||||
|
@ -1288,6 +1292,31 @@ These are the commands available for use in the file status buffer:
|
||||||
"Default absence of extra information returned for a file."
|
"Default absence of extra information returned for a file."
|
||||||
nil)
|
nil)
|
||||||
|
|
||||||
|
|
||||||
|
;;; Support for desktop.el (adapted from what dired.el does).
|
||||||
|
|
||||||
|
(declare-function desktop-file-name "desktop" (filename dirname))
|
||||||
|
|
||||||
|
(defun vc-dir-desktop-buffer-misc-data (dirname)
|
||||||
|
"Auxiliary information to be saved in desktop file."
|
||||||
|
(cons (desktop-file-name default-directory dirname) vc-dir-backend))
|
||||||
|
|
||||||
|
(defun vc-dir-restore-desktop-buffer (_filename _buffername misc-data)
|
||||||
|
"Restore a `vc-dir' buffer specified in a desktop file."
|
||||||
|
(let ((dir (car misc-data))
|
||||||
|
(backend (cdr misc-data)))
|
||||||
|
(if (file-directory-p dir)
|
||||||
|
(progn
|
||||||
|
(vc-dir dir backend)
|
||||||
|
(current-buffer))
|
||||||
|
(message "Desktop: Directory %s no longer exists." dir)
|
||||||
|
(when desktop-missing-file-warning (sit-for 1))
|
||||||
|
nil)))
|
||||||
|
|
||||||
|
(add-to-list 'desktop-buffer-mode-handlers
|
||||||
|
'(vc-dir-mode . vc-dir-restore-desktop-buffer))
|
||||||
|
|
||||||
|
|
||||||
(provide 'vc-dir)
|
(provide 'vc-dir)
|
||||||
|
|
||||||
;;; vc-dir.el ends here
|
;;; vc-dir.el ends here
|
||||||
|
|
Loading…
Add table
Reference in a new issue