aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlenn Morris2015-05-25 23:27:55 -0700
committerGlenn Morris2015-05-25 23:27:55 -0700
commitdb87b14e7c9368e231fb0396bc4fd1aad56cf849 (patch)
tree4dfe84d6c4884e0c91d4564be1f0377b565918fc
parent816a2b369d0490e67fd5a57c9f18bb2c533e80e4 (diff)
downloademacs-db87b14e7c9368e231fb0396bc4fd1aad56cf849.tar.gz
emacs-db87b14e7c9368e231fb0396bc4fd1aad56cf849.zip
* lisp/desktop.el: If modes aren't autoloaded, try simple guesswork.
(desktop-load-file): Guess that "foobar" defines "foobar-mode". (desktop-buffer-mode-handlers, desktop-minor-mode-handlers): Doc updates. (vc-dir-mode): Remove unnecessary autoload. ; Ref: http://debbugs.gnu.org/19226#14
-rw-r--r--lisp/desktop.el32
1 files changed, 22 insertions, 10 deletions
diff --git a/lisp/desktop.el b/lisp/desktop.el
index fb803b4df5b..c168f9c9d9a 100644
--- a/lisp/desktop.el
+++ b/lisp/desktop.el
@@ -83,8 +83,10 @@
83;; (add-to-list 'desktop-minor-mode-handlers 83;; (add-to-list 'desktop-minor-mode-handlers
84;; '(bar-mode . bar-desktop-restore)) 84;; '(bar-mode . bar-desktop-restore))
85 85
86;; in the module itself, and make sure that the mode function is 86;; in the module itself. The mode function must either be autoloaded,
87;; autoloaded. See the docstrings of `desktop-buffer-mode-handlers' and 87;; or of the form "foobar-mode" and defined in library "foobar", so that
88;; desktop can guess how to load its definition.
89;; See the docstrings of `desktop-buffer-mode-handlers' and
88;; `desktop-minor-mode-handlers' for more info. 90;; `desktop-minor-mode-handlers' for more info.
89 91
90;; Minor modes. 92;; Minor modes.
@@ -520,7 +522,9 @@ code like
520 (add-to-list 'desktop-buffer-mode-handlers 522 (add-to-list 'desktop-buffer-mode-handlers
521 '(foo-mode . foo-restore-desktop-buffer)) 523 '(foo-mode . foo-restore-desktop-buffer))
522 524
523Furthermore the major mode function must be autoloaded.") 525The major mode function must either be autoloaded, or of the form
526\"foobar-mode\" and defined in library \"foobar\", so that desktop
527can guess how to load the mode's definition.")
524 528
525;;;###autoload 529;;;###autoload
526(put 'desktop-buffer-mode-handlers 'risky-local-variable t) 530(put 'desktop-buffer-mode-handlers 'risky-local-variable t)
@@ -585,7 +589,9 @@ code like
585 (add-to-list 'desktop-minor-mode-handlers 589 (add-to-list 'desktop-minor-mode-handlers
586 '(foo-mode . foo-desktop-restore)) 590 '(foo-mode . foo-desktop-restore))
587 591
588Furthermore the minor mode function must be autoloaded. 592The minor mode function must either be autoloaded, or of the form
593\"foobar-mode\" and defined in library \"foobar\", so that desktop
594can guess how to load the mode's definition.
589 595
590See also `desktop-minor-mode-table'.") 596See also `desktop-minor-mode-table'.")
591 597
@@ -1352,9 +1358,18 @@ after that many seconds of idle time."
1352 nil))) 1358 nil)))
1353 1359
1354(defun desktop-load-file (function) 1360(defun desktop-load-file (function)
1355 "Load the file where auto loaded FUNCTION is defined." 1361 "Load the file where auto loaded FUNCTION is defined.
1356 (when (fboundp function) 1362If FUNCTION is not currently defined, guess the library that defines it
1357 (autoload-do-load (symbol-function function) function))) 1363and try to load that."
1364 (if (fboundp function)
1365 (autoload-do-load (symbol-function function) function)
1366 ;; Guess that foobar-mode is defined in foobar.
1367 ;; TODO rather than guessing or requiring an autoload, the desktop
1368 ;; file should record the name of the library.
1369 (let ((name (symbol-name function)))
1370 (if (string-match "\\`\\(.*\\)-mode\\'" name)
1371 (with-demoted-errors "Require error in desktop-load-file: %S"
1372 (require (intern (match-string 1 name)) nil t))))))
1358 1373
1359;; ---------------------------------------------------------------------------- 1374;; ----------------------------------------------------------------------------
1360;; Create a buffer, load its file, set its mode, ...; 1375;; Create a buffer, load its file, set its mode, ...;
@@ -1572,9 +1587,6 @@ If there are no buffers left to create, kill the timer."
1572 (desktop-read) 1587 (desktop-read)
1573 (setq inhibit-startup-screen t))))) 1588 (setq inhibit-startup-screen t)))))
1574 1589
1575;; So we can restore vc-dir buffers.
1576(autoload 'vc-dir-mode "vc-dir" nil t)
1577
1578(provide 'desktop) 1590(provide 'desktop)
1579 1591
1580;;; desktop.el ends here 1592;;; desktop.el ends here