diff options
| author | Stefan Monnier | 2025-04-22 11:52:15 -0400 |
|---|---|---|
| committer | Stefan Monnier | 2025-04-22 11:52:15 -0400 |
| commit | 2bf3790f374e0a162e05a470940f57b43a244ad7 (patch) | |
| tree | 95544a47d8e84453dcdee4135513addcebbeff88 | |
| parent | 057e990fba0975dae06bc365157dd4ff95bfd7a7 (diff) | |
| download | emacs-2bf3790f374e0a162e05a470940f57b43a244ad7.tar.gz emacs-2bf3790f374e0a162e05a470940f57b43a244ad7.zip | |
desktop.el: Janitorial cleanup
* lisp/desktop.el: Remove redundant `:group` arguments.
Prefer #' to quote function names.
(desktop-var-serdes-funs): Improve docstring markup.
(desktop-clear, desktop-create-buffer): Use lexical-binding.
(desktop--v2s): Avoid (ab)use of ,@ which doesn't splice a list.
(desktop-outvar): Strength-reduce `eval` => `symbol-value`.
(desktop-create-buffer): Don't assume point-min==1.
(desktop-buffer): Belatedly mark as obsolete.
(desktop-read): Use `locate-file`.
| -rw-r--r-- | lisp/desktop.el | 92 |
1 files changed, 36 insertions, 56 deletions
diff --git a/lisp/desktop.el b/lisp/desktop.el index b19889c5c42..a0492770517 100644 --- a/lisp/desktop.el +++ b/lisp/desktop.el | |||
| @@ -174,7 +174,7 @@ to t, or add this line in your init file: | |||
| 174 | (desktop-save-mode 1) | 174 | (desktop-save-mode 1) |
| 175 | 175 | ||
| 176 | When this mode is enabled, Emacs will save the desktop when it exits | 176 | When this mode is enabled, Emacs will save the desktop when it exits |
| 177 | (this may prompt you, see the option `desktop-save'). The next time | 177 | \(this may prompt you, see the option `desktop-save'). The next time |
| 178 | Emacs starts, if this mode is active it will restore the desktop. | 178 | Emacs starts, if this mode is active it will restore the desktop. |
| 179 | 179 | ||
| 180 | To manually save the desktop at any time, use the command \\[desktop-save]. | 180 | To manually save the desktop at any time, use the command \\[desktop-save]. |
| @@ -187,7 +187,6 @@ To see all the options you can set, browse the `desktop' customization group. | |||
| 187 | 187 | ||
| 188 | For further details, see info node `(emacs)Saving Emacs Sessions'." | 188 | For further details, see info node `(emacs)Saving Emacs Sessions'." |
| 189 | :global t | 189 | :global t |
| 190 | :group 'desktop | ||
| 191 | (if desktop-save-mode | 190 | (if desktop-save-mode |
| 192 | (desktop-auto-save-enable) | 191 | (desktop-auto-save-enable) |
| 193 | (desktop-auto-save-disable))) | 192 | (desktop-auto-save-disable))) |
| @@ -217,7 +216,6 @@ determine where the desktop is saved." | |||
| 217 | (const :tag "Ask if desktop file exists, else don't save" ask-if-exists) | 216 | (const :tag "Ask if desktop file exists, else don't save" ask-if-exists) |
| 218 | (const :tag "Save if desktop file exists, else don't" if-exists) | 217 | (const :tag "Save if desktop file exists, else don't" if-exists) |
| 219 | (const :tag "Never save" nil)) | 218 | (const :tag "Never save" nil)) |
| 220 | :group 'desktop | ||
| 221 | :version "22.1") | 219 | :version "22.1") |
| 222 | 220 | ||
| 223 | (defcustom desktop-auto-save-timeout auto-save-timeout | 221 | (defcustom desktop-auto-save-timeout auto-save-timeout |
| @@ -234,7 +232,6 @@ Zero or nil means disable auto-saving due to idleness." | |||
| 234 | (if (and (integerp value) (> value 0)) | 232 | (if (and (integerp value) (> value 0)) |
| 235 | (desktop-auto-save-enable value) | 233 | (desktop-auto-save-enable value) |
| 236 | (desktop-auto-save-disable)))) | 234 | (desktop-auto-save-disable)))) |
| 237 | :group 'desktop | ||
| 238 | :version "24.4") | 235 | :version "24.4") |
| 239 | 236 | ||
| 240 | (defcustom desktop-load-locked-desktop 'ask | 237 | (defcustom desktop-load-locked-desktop 'ask |
| @@ -260,27 +257,23 @@ case if you have remotely mounted (NFS) paths in | |||
| 260 | (const :tag "Don't load" nil) | 257 | (const :tag "Don't load" nil) |
| 261 | (const :tag "Ask the user" ask) | 258 | (const :tag "Ask the user" ask) |
| 262 | (const :tag "Load if no local process" check-pid)) | 259 | (const :tag "Load if no local process" check-pid)) |
| 263 | :group 'desktop | ||
| 264 | :version "22.2") | 260 | :version "22.2") |
| 265 | 261 | ||
| 266 | (defcustom desktop-base-file-name | 262 | (defcustom desktop-base-file-name |
| 267 | (convert-standard-filename ".emacs.desktop") | 263 | (convert-standard-filename ".emacs.desktop") |
| 268 | "Name of file for Emacs desktop, excluding the directory part." | 264 | "Name of file for Emacs desktop, excluding the directory part." |
| 269 | :type 'file | 265 | :type 'file) |
| 270 | :group 'desktop) | ||
| 271 | 266 | ||
| 272 | (defcustom desktop-base-lock-name | 267 | (defcustom desktop-base-lock-name |
| 273 | (convert-standard-filename ".emacs.desktop.lock") | 268 | (convert-standard-filename ".emacs.desktop.lock") |
| 274 | "Name of lock file for Emacs desktop, excluding the directory part." | 269 | "Name of lock file for Emacs desktop, excluding the directory part." |
| 275 | :type 'file | 270 | :type 'file |
| 276 | :group 'desktop | ||
| 277 | :version "22.2") | 271 | :version "22.2") |
| 278 | 272 | ||
| 279 | (defcustom desktop-path (list user-emacs-directory "~") | 273 | (defcustom desktop-path (list user-emacs-directory "~") |
| 280 | "List of directories to search for the desktop file. | 274 | "List of directories to search for the desktop file. |
| 281 | The base name of the file is specified in `desktop-base-file-name'." | 275 | The base name of the file is specified in `desktop-base-file-name'." |
| 282 | :type '(repeat directory) | 276 | :type '(repeat directory) |
| 283 | :group 'desktop | ||
| 284 | :version "23.2") ; user-emacs-directory added | 277 | :version "23.2") ; user-emacs-directory added |
| 285 | 278 | ||
| 286 | (defcustom desktop-missing-file-warning nil | 279 | (defcustom desktop-missing-file-warning nil |
| @@ -290,7 +283,6 @@ Also pause for a moment to display message about errors signaled in | |||
| 290 | 283 | ||
| 291 | If nil, just print error messages in the message buffer." | 284 | If nil, just print error messages in the message buffer." |
| 292 | :type 'boolean | 285 | :type 'boolean |
| 293 | :group 'desktop | ||
| 294 | :version "22.1") | 286 | :version "22.1") |
| 295 | 287 | ||
| 296 | (defcustom desktop-no-desktop-file-hook nil | 288 | (defcustom desktop-no-desktop-file-hook nil |
| @@ -298,7 +290,6 @@ If nil, just print error messages in the message buffer." | |||
| 298 | Run in the directory in which the desktop file was sought. | 290 | Run in the directory in which the desktop file was sought. |
| 299 | May be used to show a Dired buffer." | 291 | May be used to show a Dired buffer." |
| 300 | :type 'hook | 292 | :type 'hook |
| 301 | :group 'desktop | ||
| 302 | :version "22.1") | 293 | :version "22.1") |
| 303 | 294 | ||
| 304 | (defcustom desktop-not-loaded-hook nil | 295 | (defcustom desktop-not-loaded-hook nil |
| @@ -306,7 +297,6 @@ May be used to show a Dired buffer." | |||
| 306 | Run in the directory in which the desktop file was found. | 297 | Run in the directory in which the desktop file was found. |
| 307 | May be used to deal with accidental multiple Emacs jobs." | 298 | May be used to deal with accidental multiple Emacs jobs." |
| 308 | :type 'hook | 299 | :type 'hook |
| 309 | :group 'desktop | ||
| 310 | :options '(desktop-save-mode-off save-buffers-kill-emacs) | 300 | :options '(desktop-save-mode-off save-buffers-kill-emacs) |
| 311 | :version "22.2") | 301 | :version "22.2") |
| 312 | 302 | ||
| @@ -314,7 +304,6 @@ May be used to deal with accidental multiple Emacs jobs." | |||
| 314 | "Normal hook run after a successful `desktop-read'. | 304 | "Normal hook run after a successful `desktop-read'. |
| 315 | May be used to show a buffer list." | 305 | May be used to show a buffer list." |
| 316 | :type 'hook | 306 | :type 'hook |
| 317 | :group 'desktop | ||
| 318 | :options '(list-buffers) | 307 | :options '(list-buffers) |
| 319 | :version "22.1") | 308 | :version "22.1") |
| 320 | 309 | ||
| @@ -323,8 +312,7 @@ May be used to show a buffer list." | |||
| 323 | Run with the desktop buffer current with only the header present. | 312 | Run with the desktop buffer current with only the header present. |
| 324 | May be used to add to the desktop code or to truncate history lists, | 313 | May be used to add to the desktop code or to truncate history lists, |
| 325 | for example." | 314 | for example." |
| 326 | :type 'hook | 315 | :type 'hook) |
| 327 | :group 'desktop) | ||
| 328 | 316 | ||
| 329 | (defcustom desktop-globals-to-save | 317 | (defcustom desktop-globals-to-save |
| 330 | '(desktop-missing-file-warning | 318 | '(desktop-missing-file-warning |
| @@ -339,8 +327,7 @@ An element may be variable name (a symbol) or a cons cell of the form | |||
| 339 | \(VAR . MAX-SIZE), which means to truncate VAR's value to at most | 327 | \(VAR . MAX-SIZE), which means to truncate VAR's value to at most |
| 340 | MAX-SIZE elements (if the value is a list) before saving the value. | 328 | MAX-SIZE elements (if the value is a list) before saving the value. |
| 341 | Feature: Saving `kill-ring' implies saving `kill-ring-yank-pointer'." | 329 | Feature: Saving `kill-ring' implies saving `kill-ring-yank-pointer'." |
| 342 | :type '(repeat (restricted-sexp :match-alternatives (symbolp consp))) | 330 | :type '(repeat (restricted-sexp :match-alternatives (symbolp consp)))) |
| 343 | :group 'desktop) | ||
| 344 | 331 | ||
| 345 | (defcustom desktop-globals-to-clear | 332 | (defcustom desktop-globals-to-clear |
| 346 | '(kill-ring | 333 | '(kill-ring |
| @@ -354,7 +341,6 @@ An element may be variable name (a symbol) or a cons cell of the form | |||
| 354 | \(VAR . FORM). Symbols are set to nil and for cons cells VAR is set | 341 | \(VAR . FORM). Symbols are set to nil and for cons cells VAR is set |
| 355 | to the value obtained by evaluating FORM." | 342 | to the value obtained by evaluating FORM." |
| 356 | :type '(repeat (restricted-sexp :match-alternatives (symbolp consp))) | 343 | :type '(repeat (restricted-sexp :match-alternatives (symbolp consp))) |
| 357 | :group 'desktop | ||
| 358 | :version "22.1") | 344 | :version "22.1") |
| 359 | 345 | ||
| 360 | (defcustom desktop-clear-preserve-buffers | 346 | (defcustom desktop-clear-preserve-buffers |
| @@ -364,8 +350,7 @@ to the value obtained by evaluating FORM." | |||
| 364 | Each element is a regular expression. Buffers with a name matched by any of | 350 | Each element is a regular expression. Buffers with a name matched by any of |
| 365 | these won't be deleted." | 351 | these won't be deleted." |
| 366 | :version "23.3" ; added Warnings - bug#6336 | 352 | :version "23.3" ; added Warnings - bug#6336 |
| 367 | :type '(repeat regexp) | 353 | :type '(repeat regexp)) |
| 368 | :group 'desktop) | ||
| 369 | 354 | ||
| 370 | ;;;###autoload | 355 | ;;;###autoload |
| 371 | (defcustom desktop-locals-to-save | 356 | (defcustom desktop-locals-to-save |
| @@ -389,8 +374,7 @@ these won't be deleted." | |||
| 389 | "List of local variables to save for each buffer. | 374 | "List of local variables to save for each buffer. |
| 390 | The variables are saved only when they really are local. Conventional minor | 375 | The variables are saved only when they really are local. Conventional minor |
| 391 | modes are restored automatically; they should not be listed here." | 376 | modes are restored automatically; they should not be listed here." |
| 392 | :type '(repeat symbol) | 377 | :type '(repeat symbol)) |
| 393 | :group 'desktop) | ||
| 394 | 378 | ||
| 395 | (defcustom desktop-buffers-not-to-save "\\` " | 379 | (defcustom desktop-buffers-not-to-save "\\` " |
| 396 | "Regexp identifying buffers that are to be excluded from saving. | 380 | "Regexp identifying buffers that are to be excluded from saving. |
| @@ -399,8 +383,7 @@ To exclude buffers that visit files, use `desktop-files-not-to-save' | |||
| 399 | or `desktop-modes-not-to-save'." | 383 | or `desktop-modes-not-to-save'." |
| 400 | :type '(choice (const :tag "None" nil) | 384 | :type '(choice (const :tag "None" nil) |
| 401 | regexp) | 385 | regexp) |
| 402 | :version "24.4" ; skip invisible temporary buffers | 386 | :version "24.4") ; skip invisible temporary buffers |
| 403 | :group 'desktop) | ||
| 404 | 387 | ||
| 405 | ;; Skip tramp and ange-ftp files | 388 | ;; Skip tramp and ange-ftp files |
| 406 | (defcustom desktop-files-not-to-save | 389 | (defcustom desktop-files-not-to-save |
| @@ -413,15 +396,13 @@ you may wish customizing `remote-file-name-access-timeout' to a non-nil | |||
| 413 | value, to avoid hanging the desktop restoration because some remote | 396 | value, to avoid hanging the desktop restoration because some remote |
| 414 | host is off-line." | 397 | host is off-line." |
| 415 | :type '(choice (const :tag "None" nil) | 398 | :type '(choice (const :tag "None" nil) |
| 416 | regexp) | 399 | regexp)) |
| 417 | :group 'desktop) | ||
| 418 | 400 | ||
| 419 | ;; We skip TAGS files to save time (tags-file-name is saved instead). | 401 | ;; We skip TAGS files to save time (tags-file-name is saved instead). |
| 420 | (defcustom desktop-modes-not-to-save | 402 | (defcustom desktop-modes-not-to-save |
| 421 | '(tags-table-mode) | 403 | '(tags-table-mode) |
| 422 | "List of major modes whose buffers should not be saved." | 404 | "List of major modes whose buffers should not be saved." |
| 423 | :type '(repeat symbol) | 405 | :type '(repeat symbol)) |
| 424 | :group 'desktop) | ||
| 425 | 406 | ||
| 426 | (defcustom desktop-restore-frames (not (featurep 'android)) | 407 | (defcustom desktop-restore-frames (not (featurep 'android)) |
| 427 | "When non-nil, save and restore the frame and window configuration. | 408 | "When non-nil, save and restore the frame and window configuration. |
| @@ -432,7 +413,6 @@ This option is enabled by default, except on Android. It is disabled by | |||
| 432 | default on Android because the window manager there prevents programs from | 413 | default on Android because the window manager there prevents programs from |
| 433 | restoring frames." | 414 | restoring frames." |
| 434 | :type 'boolean | 415 | :type 'boolean |
| 435 | :group 'desktop | ||
| 436 | :version "31.1") | 416 | :version "31.1") |
| 437 | 417 | ||
| 438 | (defcustom desktop-restore-in-current-display t | 418 | (defcustom desktop-restore-in-current-display t |
| @@ -443,7 +423,6 @@ If `delete', deletes frames on other displays instead of restoring them." | |||
| 443 | :type '(choice (const :tag "Restore in current display" t) | 423 | :type '(choice (const :tag "Restore in current display" t) |
| 444 | (const :tag "Restore in original display" nil) | 424 | (const :tag "Restore in original display" nil) |
| 445 | (const :tag "Delete frames in other displays" delete)) | 425 | (const :tag "Delete frames in other displays" delete)) |
| 446 | :group 'desktop | ||
| 447 | :version "24.4") | 426 | :version "24.4") |
| 448 | 427 | ||
| 449 | (defcustom desktop-restore-forces-onscreen t | 428 | (defcustom desktop-restore-forces-onscreen t |
| @@ -459,7 +438,6 @@ no effect on restoring frames in a non-GUI session." | |||
| 459 | :type '(choice (const :tag "Only fully offscreen frames" t) | 438 | :type '(choice (const :tag "Only fully offscreen frames" t) |
| 460 | (const :tag "Also partially offscreen frames" all) | 439 | (const :tag "Also partially offscreen frames" all) |
| 461 | (const :tag "Do not force frames onscreen" nil)) | 440 | (const :tag "Do not force frames onscreen" nil)) |
| 462 | :group 'desktop | ||
| 463 | :version "24.4") | 441 | :version "24.4") |
| 464 | 442 | ||
| 465 | (defcustom desktop-restore-reuses-frames t | 443 | (defcustom desktop-restore-reuses-frames t |
| @@ -469,7 +447,6 @@ If `keep', keeps existing frames and does not reuse them." | |||
| 469 | :type '(choice (const :tag "Reuse existing frames" t) | 447 | :type '(choice (const :tag "Reuse existing frames" t) |
| 470 | (const :tag "Delete existing frames" nil) | 448 | (const :tag "Delete existing frames" nil) |
| 471 | (const :tag "Keep existing frames" keep)) | 449 | (const :tag "Keep existing frames" keep)) |
| 472 | :group 'desktop | ||
| 473 | :version "24.4") | 450 | :version "24.4") |
| 474 | 451 | ||
| 475 | (defcustom desktop-file-name-format 'absolute | 452 | (defcustom desktop-file-name-format 'absolute |
| @@ -479,7 +456,6 @@ Possible values are: | |||
| 479 | tilde -- Relative to ~. | 456 | tilde -- Relative to ~. |
| 480 | local -- Relative to directory of desktop file." | 457 | local -- Relative to directory of desktop file." |
| 481 | :type '(choice (const absolute) (const tilde) (const local)) | 458 | :type '(choice (const absolute) (const tilde) (const local)) |
| 482 | :group 'desktop | ||
| 483 | :version "22.1") | 459 | :version "22.1") |
| 484 | 460 | ||
| 485 | (defcustom desktop-restore-eager t | 461 | (defcustom desktop-restore-eager t |
| @@ -487,20 +463,17 @@ Possible values are: | |||
| 487 | Remaining buffers are restored lazily (when Emacs is idle). | 463 | Remaining buffers are restored lazily (when Emacs is idle). |
| 488 | If value is t, all buffers are restored immediately." | 464 | If value is t, all buffers are restored immediately." |
| 489 | :type '(choice (const t) integer) | 465 | :type '(choice (const t) integer) |
| 490 | :group 'desktop | ||
| 491 | :version "22.1") | 466 | :version "22.1") |
| 492 | 467 | ||
| 493 | (defcustom desktop-lazy-verbose t | 468 | (defcustom desktop-lazy-verbose t |
| 494 | "Verbose reporting of lazily created buffers." | 469 | "Verbose reporting of lazily created buffers." |
| 495 | :type 'boolean | 470 | :type 'boolean |
| 496 | :group 'desktop | ||
| 497 | :version "22.1") | 471 | :version "22.1") |
| 498 | 472 | ||
| 499 | (defcustom desktop-lazy-idle-delay 5 | 473 | (defcustom desktop-lazy-idle-delay 5 |
| 500 | "Idle delay before starting to create buffers. | 474 | "Idle delay before starting to create buffers. |
| 501 | See `desktop-restore-eager'." | 475 | See `desktop-restore-eager'." |
| 502 | :type 'natnum | 476 | :type 'natnum |
| 503 | :group 'desktop | ||
| 504 | :version "22.1") | 477 | :version "22.1") |
| 505 | 478 | ||
| 506 | ;;;###autoload | 479 | ;;;###autoload |
| @@ -578,8 +551,7 @@ and the name of the minor mode function are different have to be added to | |||
| 578 | this table. See also `desktop-minor-mode-handlers'." | 551 | this table. See also `desktop-minor-mode-handlers'." |
| 579 | :type '(alist :key-type (symbol :tag "Minor mode") | 552 | :type '(alist :key-type (symbol :tag "Minor mode") |
| 580 | :value-type (list :tag "Restore function" | 553 | :value-type (list :tag "Restore function" |
| 581 | (choice (const nil) function))) | 554 | (choice (const nil) function)))) |
| 582 | :group 'desktop) | ||
| 583 | 555 | ||
| 584 | ;;;###autoload | 556 | ;;;###autoload |
| 585 | (defvar desktop-minor-mode-handlers nil | 557 | (defvar desktop-minor-mode-handlers nil |
| @@ -682,7 +654,7 @@ Used to detect desktop file conflicts.") | |||
| 682 | (lambda (mr) | 654 | (lambda (mr) |
| 683 | (mapcar #'copy-marker mr)))) | 655 | (mapcar #'copy-marker mr)))) |
| 684 | "Table of serialization/deserialization functions for variables. | 656 | "Table of serialization/deserialization functions for variables. |
| 685 | Each record is a list of form: (var serializer deserializer). | 657 | Each record is a list of form: (VAR SERIALIZER DESERIALIZER). |
| 686 | These records can be freely reordered, deleted, or new ones added. | 658 | These records can be freely reordered, deleted, or new ones added. |
| 687 | However, for compatibility, don't modify the functions for existing records.") | 659 | However, for compatibility, don't modify the functions for existing records.") |
| 688 | 660 | ||
| @@ -774,7 +746,9 @@ if different)." | |||
| 774 | (dolist (var desktop-globals-to-clear) | 746 | (dolist (var desktop-globals-to-clear) |
| 775 | (if (symbolp var) | 747 | (if (symbolp var) |
| 776 | (set-default var nil) | 748 | (set-default var nil) |
| 777 | (set-default var (eval (cdr var))))) | 749 | ;; FIXME: To avoid maiming kitten we should also support `funcall' |
| 750 | ;; instead of only `eval' here. | ||
| 751 | (set-default var (eval (cdr var) t)))) | ||
| 778 | (let ((preserve-regexp (concat "\\`\\(" | 752 | (let ((preserve-regexp (concat "\\`\\(" |
| 779 | (mapconcat (lambda (regexp) | 753 | (mapconcat (lambda (regexp) |
| 780 | (concat "\\(" regexp "\\)")) | 754 | (concat "\\(" regexp "\\)")) |
| @@ -866,7 +840,7 @@ buffer, which is (in order): | |||
| 866 | `buffer-file-name'; | 840 | `buffer-file-name'; |
| 867 | `buffer-name'; | 841 | `buffer-name'; |
| 868 | `major-mode'; | 842 | `major-mode'; |
| 869 | list of minor-modes,; | 843 | list of minor-modes; |
| 870 | `point'; | 844 | `point'; |
| 871 | `mark'; | 845 | `mark'; |
| 872 | `buffer-read-only'; | 846 | `buffer-read-only'; |
| @@ -980,7 +954,7 @@ QUOTE may be `may' (value may be quoted), | |||
| 980 | (cons 'must | 954 | (cons 'must |
| 981 | `(,@(mapcar #'cdr | 955 | `(,@(mapcar #'cdr |
| 982 | (nreverse (if use-list* (cdr newlist) newlist))) | 956 | (nreverse (if use-list* (cdr newlist) newlist))) |
| 983 | ,@(if use-list* (cdar newlist))))))) | 957 | . ,(if use-list* (cdar newlist))))))) |
| 984 | ((subrp value) | 958 | ((subrp value) |
| 985 | (cons nil `(symbol-function | 959 | (cons nil `(symbol-function |
| 986 | ',(intern-soft (substring (prin1-to-string value) 7 -1))))) | 960 | ',(intern-soft (substring (prin1-to-string value) 7 -1))))) |
| @@ -1026,8 +1000,8 @@ which means to truncate VAR's value to at most MAX-SIZE elements | |||
| 1026 | (when (boundp var) | 1000 | (when (boundp var) |
| 1027 | (when (and (integerp size) | 1001 | (when (and (integerp size) |
| 1028 | (> size 0) | 1002 | (> size 0) |
| 1029 | (listp (eval var))) | 1003 | (listp (symbol-value var))) |
| 1030 | (desktop-truncate (eval var) size)) | 1004 | (desktop-truncate (symbol-value var) size)) |
| 1031 | (insert "(setq " | 1005 | (insert "(setq " |
| 1032 | (symbol-name var) | 1006 | (symbol-name var) |
| 1033 | " " | 1007 | " " |
| @@ -1046,7 +1020,7 @@ have its state saved in the desktop file.") | |||
| 1046 | "Return t if buffer should have its state saved in the desktop file. | 1020 | "Return t if buffer should have its state saved in the desktop file. |
| 1047 | FILENAME is the visited file name, BUFNAME is the buffer name, and | 1021 | FILENAME is the visited file name, BUFNAME is the buffer name, and |
| 1048 | MODE is the major mode. | 1022 | MODE is the major mode. |
| 1049 | \n\(fn FILENAME BUFNAME MODE)" | 1023 | \n(fn FILENAME BUFNAME MODE)" |
| 1050 | (let ((case-fold-search nil) | 1024 | (let ((case-fold-search nil) |
| 1051 | (no-regexp-to-check (not (stringp desktop-files-not-to-save))) | 1025 | (no-regexp-to-check (not (stringp desktop-files-not-to-save))) |
| 1052 | dired-skip) | 1026 | dired-skip) |
| @@ -1339,14 +1313,9 @@ It returns t if a desktop file was loaded, nil otherwise. | |||
| 1339 | ;; Else, with a prefix arg, ask for a directory name. | 1313 | ;; Else, with a prefix arg, ask for a directory name. |
| 1340 | (and ask (read-directory-name "Directory for desktop file: " nil nil t)) | 1314 | (and ask (read-directory-name "Directory for desktop file: " nil nil t)) |
| 1341 | ;; Otherwise search desktop file in desktop-path. | 1315 | ;; Otherwise search desktop file in desktop-path. |
| 1342 | (let ((dirs desktop-path)) | 1316 | (locate-file desktop-base-file-name desktop-path) |
| 1343 | (while (and dirs | ||
| 1344 | (not (file-exists-p | ||
| 1345 | (desktop-full-file-name (car dirs))))) | ||
| 1346 | (setq dirs (cdr dirs))) | ||
| 1347 | (and dirs (car dirs))) | ||
| 1348 | ;; If not found and `desktop-path' is non-nil, use its first element. | 1317 | ;; If not found and `desktop-path' is non-nil, use its first element. |
| 1349 | (and desktop-path (car desktop-path)) | 1318 | (car desktop-path) |
| 1350 | ;; Default: .emacs.d. | 1319 | ;; Default: .emacs.d. |
| 1351 | user-emacs-directory)))) | 1320 | user-emacs-directory)))) |
| 1352 | (if (file-exists-p (desktop-full-file-name)) | 1321 | (if (file-exists-p (desktop-full-file-name)) |
| @@ -1498,7 +1467,7 @@ This function is called from `window-configuration-change-hook'." | |||
| 1498 | (> desktop-auto-save-timeout 0)) | 1467 | (> desktop-auto-save-timeout 0)) |
| 1499 | (setq desktop-auto-save-timer | 1468 | (setq desktop-auto-save-timer |
| 1500 | (run-with-idle-timer desktop-auto-save-timeout nil | 1469 | (run-with-idle-timer desktop-auto-save-timeout nil |
| 1501 | 'desktop-auto-save)))) | 1470 | #'desktop-auto-save)))) |
| 1502 | 1471 | ||
| 1503 | (defun desktop-auto-save-cancel-timer () | 1472 | (defun desktop-auto-save-cancel-timer () |
| 1504 | (when desktop-auto-save-timer | 1473 | (when desktop-auto-save-timer |
| @@ -1657,8 +1626,16 @@ and try to load that." | |||
| 1657 | (condition-case err | 1626 | (condition-case err |
| 1658 | ;; Evaluate point. Thus point can be something like | 1627 | ;; Evaluate point. Thus point can be something like |
| 1659 | ;; '(search-forward ... | 1628 | ;; '(search-forward ... |
| 1660 | (eval desktop-buffer-point) | 1629 | ;; FIXME: How/where could this happen? AFAICT this var |
| 1661 | (error (message "%s" (error-message-string err)) 1)))) | 1630 | ;; is lexical has been lexical since 2013 and thus equal |
| 1631 | ;; to the arg `buffer-point' which always comes from the | ||
| 1632 | ;; corresponding entry in `desktop-buffer-info' where we | ||
| 1633 | ;; put just an integer. | ||
| 1634 | ;; FIXME: If we want to keep this feature, we should | ||
| 1635 | ;; also allow `desktop-buffer-point' to be a function. | ||
| 1636 | (eval desktop-buffer-point t) | ||
| 1637 | (error (message "%s" (error-message-string err)) | ||
| 1638 | (point-min))))) | ||
| 1662 | (when desktop-buffer-mark | 1639 | (when desktop-buffer-mark |
| 1663 | (if (consp desktop-buffer-mark) | 1640 | (if (consp desktop-buffer-mark) |
| 1664 | (progn | 1641 | (progn |
| @@ -1701,6 +1678,8 @@ and try to load that." | |||
| 1701 | ;; Backward compatibility -- update parameters to 205 standards. | 1678 | ;; Backward compatibility -- update parameters to 205 standards. |
| 1702 | (defun desktop-buffer (buffer-filename buffer-name buffer-majormode | 1679 | (defun desktop-buffer (buffer-filename buffer-name buffer-majormode |
| 1703 | mim pt mk ro tl fc cfs cr buffer-misc) | 1680 | mim pt mk ro tl fc cfs cr buffer-misc) |
| 1681 | ;; FIXME: Actually, it's been obsolete since 1994 (commit ec4c6f225a81)! | ||
| 1682 | (declare (obsolete desktop-create-buffer "31")) | ||
| 1704 | (desktop-create-buffer 205 buffer-filename buffer-name | 1683 | (desktop-create-buffer 205 buffer-filename buffer-name |
| 1705 | buffer-majormode (cdr mim) pt mk ro | 1684 | buffer-majormode (cdr mim) pt mk ro |
| 1706 | buffer-misc | 1685 | buffer-misc |
| @@ -1716,7 +1695,8 @@ ARGS must be an argument list for `desktop-create-buffer'." | |||
| 1716 | (setq desktop-buffer-args-list (nconc desktop-buffer-args-list (list args))) | 1695 | (setq desktop-buffer-args-list (nconc desktop-buffer-args-list (list args))) |
| 1717 | (unless desktop-lazy-timer | 1696 | (unless desktop-lazy-timer |
| 1718 | (setq desktop-lazy-timer | 1697 | (setq desktop-lazy-timer |
| 1719 | (run-with-idle-timer desktop-lazy-idle-delay t 'desktop-idle-create-buffers)))) | 1698 | (run-with-idle-timer desktop-lazy-idle-delay t |
| 1699 | #'desktop-idle-create-buffers)))) | ||
| 1720 | 1700 | ||
| 1721 | (defun desktop-lazy-create-buffer () | 1701 | (defun desktop-lazy-create-buffer () |
| 1722 | "Pop args from `desktop-buffer-args-list', create buffer and bury it." | 1702 | "Pop args from `desktop-buffer-args-list', create buffer and bury it." |