;ELC ;;; Compiled ;;; in Emacs version 28.0.50 ;;; with all optimizations. (byte-code "\300\301\302\303\304\305\306\307&\210\310\311\312\313\314DD\315\316\313\304\301&\210\310\317\312\313\320DD\321\316\322\304\301&\210\310\323\312\313\324DD\325\316\326\304\301&\210\310\327\312\313\330DD\331\316\332\304\301&\210\310\333\312\313\334DD\335\316\336\304\301&\210\310\337\312\313\340DD\341\316\313\304\301&\210\310\342\312\313\343DD\344\316\345\304\301&\207" [custom-declare-group persistent-scratch nil "Preserve the state of scratch buffers across Emacs sessions." :group files :prefix "persistent-scratch-" custom-declare-variable persistent-scratch-scratch-buffer-p-function funcall function #[0 "\300\207" [persistent-scratch-default-scratch-buffer-p] 1] "Function determining whether the current buffer is a scratch buffer.\nWhen this function, called with no arguments, returns non-nil, the current\nbuffer is assumed to be a scratch buffer, thus becoming eligible for\n(auto-)saving." :type persistent-scratch-save-file #[0 "\301\302\"\207" [user-emacs-directory expand-file-name ".persistent-scratch"] 3] "File to save to the scratch buffers to." file persistent-scratch-what-to-save #[0 "\300\207" [(major-mode point narrowing)] 1] "Specify what scratch buffer properties to save.\n\nThe buffer name and the buffer contents are always saved.\n\nIt's a list containing some or all of the following values:\n - `major-mode': save the the major mode.\n - `point': save the positions of `point' and `mark'.\n - `narrowing': save the region the buffer is narrowed to.\n - `text-properties': save the text properties of the buffer contents." (repeat :tag "What to save" (choice :tag "State to save" (const :tag "Major mode" major-mode) (const :tag "Point and mark" point) (const :tag "Narrowing" narrowing) (const :tag "Text properties of contents" text-properties))) persistent-scratch-autosave-interval #[0 "\300\207" [300] 1] "The interval, in seconds, between autosaves of scratch buffers.\n\nSetting this variable when `persistent-scratch-autosave-mode' is already on does\nnothing, call `persistent-scratch-autosave-mode' for it to take effect." number persistent-scratch-backup-directory #[0 "\300\207" [nil] 1] "Directory to save old versions of scratch buffer saves to.\nWhen nil, backups are disabled." (choice directory (const :tag "Disabled" nil)) persistent-scratch-backup-filter #[0 "\300\207" [ignore] 1] "Function returning the list of file names of old backups to delete.\nBy default, no backups are deleted.\nThis function is called with one argument, a list of file names in\n`persistent-scratch-backup-directory'; this list is *not* sorted in any way." persistent-scratch-backup-file-name-format #[0 "\300\207" [#1="%Y-%m-%d--%H-%M-%S-%N"] 1 #1#] "Format of backup file names, for `format-time-string'." string] 8) #@514 Save the current state of scratch buffers. When FILE is non-nil, the state is saved to FILE; when nil or when called interactively, the state is saved to `persistent-scratch-save-file'. What state exactly is saved is determined by `persistent-scratch-what-to-save'. When FILE is nil and `persistent-scratch-backup-directory' is non-nil, a copy of `persistent-scratch-save-file' is stored in that directory, with a name representing the time of the last `persistent-scratch-new-backup' call. (fn &optional FILE) (defalias 'persistent-scratch-save #[256 "\211\206\211\302P\303 \304 \305\306!\210\307\310\"\216\311\312\313\313\314%\210*\266\315\316#\210\317\320!\2033\321\322\"\210\266\211?\205?\323 \210\324 \207" [persistent-scratch-save-file coding-system-for-write ".new" persistent-scratch--save-state-to-string default-file-modes set-default-file-modes 384 make-closure #[0 "\301\300!\207" [V0 set-default-file-modes] 2] utf-8-unix write-region nil 0 rename-file t called-interactively-p interactive message "Wrote persistent-scratch file %s" persistent-scratch--update-backup persistent-scratch--cleanup-backups] 11 (#$ . 2857) nil]) #@251 Save the current state of scratch buffers. The state is saved to FILE. When called interactively, prompt for the file name, which is the only difference between this function and `persistent-scratch-save'. See `persistent-scratch-save'. (fn FILE) (defalias 'persistent-scratch-save-to-file #[257 "\300!\207" [persistent-scratch-save] 3 (#$ . 4018) "F"]) #@400 Restore the scratch buffers. Load FILE and restore all saved buffers to their saved state. FILE is a file to restore scratch buffers from; when nil or when called interactively, `persistent-scratch-save-file' is used. This is a potentially destructive operation: if there's an open buffer with the same name as a saved buffer, the contents of that buffer will be overwritten. (fn &optional FILE) (defalias 'persistent-scratch-restore #[256 "\302\303\304\305\"r\211q\210\306\307\"\216\310\311\206 !\210)\312 *\262!\211\211\205v\211@r\313\314H!q\210\315 \210\211\316Hc\210\211\317H\206=\320 \210\211\321H\211\203O\211@b\210\322A!\210\210\211\323H\211\203]\211@A}\210\210\211G\324Y\203n\211\325H\204n\326 \210)A\266\202\202 \207" [coding-system-for-read persistent-scratch-save-file read generate-new-buffer " *temp*" t make-closure #[0 "\301\300!\205 \302\300!\207" [V0 buffer-name kill-buffer] 2] utf-8-unix insert-file-contents buffer-string get-buffer-create 0 erase-buffer 1 3 ignore 2 set-mark 4 6 5 deactivate-mark] 7 (#$ . 4383) nil]) #@278 Restore the scratch buffers from a file. FILE is a file storing saved scratch buffer state. When called interactively, prompt for the file name, which is the only difference between this function and `persistent-scratch-restore'. See `persistent-scratch-restore'. (fn FILE) (defalias 'persistent-scratch-restore-from-file #[257 "\300!\207" [persistent-scratch-restore] 3 (#$ . 5451) "f"]) (defvar persistent-scratch--auto-restored nil) #@60 Automatically restore the scratch buffer once per session. (defalias 'persistent-scratch--auto-restore #[0 "?\205\3011\302 0\210\202\303\304\"\266\305\211\207" [persistent-scratch--auto-restored (error) persistent-scratch-restore message "Failed to restore scratch buffers: %S" t] 4 (#$ . 5897)]) #@43 The keymap for `persistent-scratch-mode'. (defvar persistent-scratch-mode-map (byte-code "\300 \301\302\303#\210\301\304\305#\210\207" [make-sparse-keymap define-key [remap save-buffer] persistent-scratch-save [remap write-file] persistent-scratch-save-to-file] 5) (#$ . 6210)) #@115 Non-nil if Persistent-Scratch mode is enabled. Use the command `persistent-scratch-mode' to change this variable. (defvar persistent-scratch-mode nil (#$ . 6497)) (make-variable-buffer-local 'persistent-scratch-mode) #@807 Utility mode that remaps `save-buffer' and `write-file' to their `persistent-scratch' equivalents. This is a minor mode. If called interactively, toggle the `Persistent-Scratch mode' mode. If the prefix argument is positive, enable the mode, and if it is zero or negative, disable the mode. If called from Lisp, toggle the mode if ARG is `toggle'. Enable the mode if ARG is nil, omitted, or is a positive number. Disable the mode if ARG is a negative number. To check whether the minor mode is enabled in the current buffer, evaluate `persistent-scratch-mode'. The mode's hook is called both when the mode is enabled and when it is disabled. This mode cannot be enabled in buffers for which `persistent-scratch-scratch-buffer-p-function' is nil. \{persistent-scratch-mode-map} (fn &optional ARG) (defalias 'persistent-scratch-mode #[256 "\303 \304=\203 ?\202\247\203\305W\203\306\202\307\310\301!\2031\311\300 \"\2031\300 B\203@\n \204@\306\312\313!\210\314\315\203J\316\202K\317\"\210\320\321!\203m\303 \203_\211\303 \232\203m\322\323\203i\324\202j\325\326#\210\210\327 \210\207" [persistent-scratch-mode local-minor-modes persistent-scratch-scratch-buffer-p-function current-message toggle 1 nil t boundp delq error "This buffer isn't managed by `persistent-scratch', not enabling mode." run-hooks persistent-scratch-mode-hook persistent-scratch-mode-on-hook persistent-scratch-mode-off-hook called-interactively-p any message "Persistent-Scratch mode %sabled%s" "en" "dis" " in current buffer" force-mode-line-update] 6 (#$ . 6721) (byte-code "\203\n\301!\202 \302C\207" [current-prefix-arg prefix-numeric-value toggle] 2)]) (defvar persistent-scratch-mode-hook nil) (byte-code "\301\302N\204\f\303\301\302\304#\210\303\301\305\306#\210\303\301\307\310C#\210\311\312\313\314\300!\205#\310\211%\210\315\316\317\320\321DD\322\323\324\325\326\327\330& \207" [persistent-scratch-mode-map persistent-scratch-mode-hook variable-documentation put "Hook run after entering or leaving `persistent-scratch-mode'.\nNo problems result if this variable is not bound.\n`add-hook' automatically binds it. (This is true for all hook variables.)" custom-type hook standard-value nil add-minor-mode persistent-scratch-mode " PS" boundp custom-declare-variable persistent-scratch-autosave-mode funcall function #[0 "\300\207" [nil] 1] "Non-nil if Persistent-Scratch-Autosave mode is enabled.\nSee the `persistent-scratch-autosave-mode' command\nfor a description of this minor mode.\nSetting this variable directly does not take effect;\neither customize it (see the info node `Easy Customization')\nor call the function `persistent-scratch-autosave-mode'." :set custom-set-minor-mode :initialize custom-initialize-default :type boolean] 10) #@528 Autosave scratch buffer state. Every `persistent-scratch-autosave-interval' seconds and when Emacs quits, the state of all active scratch buffers is saved. This uses `persistent-scratch-save', which see. Toggle Persistent-Scratch-Autosave mode on or off. With a prefix argument ARG, enable Persistent-Scratch-Autosave mode if ARG is positive, and disable it otherwise. If called from Lisp, enable the mode if ARG is omitted or nil, and toggle it if ARG is `toggle'. \{persistent-scratch-autosave-mode-map} (fn &optional ARG) (defalias 'persistent-scratch-autosave-mode #[256 "\302 \303\301\304=\203\305\301!?\202!\247\203 \306W\203 \307\202!\310\"\210\311\300!\2038\312\301\"\305\301!\2038\301B\313 \210\314 \210 \203E\315 \210\316\317\305\301!\203Q\320\202R\321\"\210\322\323!\203z\324\301!\210\302 \203j\211\302 \232\203z\325\326\305\301!\203v\327\202w\330\331#\210\210\332 \210\305\301!\207" [global-minor-modes persistent-scratch-autosave-mode current-message set-default toggle default-value 1 nil t boundp delq persistent-scratch--auto-restore persistent-scratch--turn-autosave-off persistent-scratch--turn-autosave-on run-hooks persistent-scratch-autosave-mode-hook persistent-scratch-autosave-mode-on-hook persistent-scratch-autosave-mode-off-hook called-interactively-p any customize-mark-as-set message "Persistent-Scratch-Autosave mode %sabled%s" "en" "dis" "" force-mode-line-update] 6 (#$ . 9505) (byte-code "\203\n\301!\202 \302C\207" [current-prefix-arg prefix-numeric-value toggle] 2)]) (defvar persistent-scratch-autosave-mode-hook nil) (byte-code "\301\302N\204\f\303\301\302\304#\210\303\301\305\306#\210\303\301\307\310C#\210\311\312\313\314\300!\205#\310\211%\207" [persistent-scratch-autosave-mode-map persistent-scratch-autosave-mode-hook variable-documentation put "Hook run after entering or leaving `persistent-scratch-autosave-mode'.\nNo problems result if this variable is not bound.\n`add-hook' automatically binds it. (This is true for all hook variables.)" custom-type hook standard-value nil add-minor-mode persistent-scratch-autosave-mode "" boundp] 6) (defvar persistent-scratch--current-backup-time (current-time)) #@162 Create a new scratch buffer save backup file. The next time `persistent-scratch-save' is called, it will create a new backup file and use that file from now on. (defalias 'persistent-scratch-new-backup #[0 "\301 \211\207" [persistent-scratch--current-backup-time current-time] 2 (#$ . 11695) nil]) #@161 Enable `persistent-scratch-autosave-mode' and restore the scratch buffers. When an error occurs while restoring the scratch buffers, it's demoted to a message. (defalias 'persistent-scratch-setup-default #[0 "\300 \210\301 \207" [persistent-scratch--auto-restore persistent-scratch-autosave-mode] 1 (#$ . 12001)]) #@60 Return non-nil iff the current buffer's name is *scratch*. (defalias 'persistent-scratch-default-scratch-buffer-p #[0 "\300 \301\230\207" [buffer-name "*scratch*"] 2 (#$ . 12321)]) #@309 Return a backup filter that keeps N newest backups. The returned function is suitable for `persistent-scratch-backup-filter'. Note: this function assumes that increasing time values result in lexicographically increasing file names when formatted using `persistent-scratch-backup-file-name-format'. (fn N) (defalias 'persistent-scratch-keep-n-newest-backups #[257 "\300\301\"\207" [make-closure #[257 "\300\301\302\"\233\207" [V0 sort #[514 "\211\231\207" [] 4 "\n\n(fn A B)"]] 5 "\n\n(fn FILES)"]] 4 (#$ . 12509)]) #@461 Return a backup filter that keeps backups newer than DIFF. DIFF may be either a number representing the number of second, or a time value in the format returned by `current-time' or `seconds-to-time'. The returned function is suitable for `persistent-scratch-backup-filter'. Note: this function assumes that increasing time values result in lexicographically increasing file names when formatted using `persistent-scratch-backup-file-name-format'. (fn DIFF) (defalias 'persistent-scratch-keep-backups-not-older-than #[257 "\211C\211\242\247\203\211\300\242!\240\210\301\302\"\207" [seconds-to-time make-closure #[257 "\302 \303\304 \300\242\"\"\305\306\307\310\311\"\"\"\207" [V0 persistent-scratch-backup-file-name-format format-time-string time-subtract current-time delq nil mapcar make-closure #[257 "\211\300\231\205\211\207" [V0] 3 "\n\n(fn FILE)"]] 8 "\n\n(fn FILES)"]] 5 (#$ . 13037)]) #@56 Save the current state of scratch buffers to a string. (defalias 'persistent-scratch--save-state-to-string #[0 "\306\307 \211\203 \211@r\211q\210 \203\310 B\262)A\266\202\202\210\311\211\211\306\211\211 \312!.\207" [persistent-scratch-scratch-buffer-p-function print-level print-length print-escape-newlines print-gensym print-circle nil buffer-list persistent-scratch--get-buffer-state t prin1-to-string print-quoted] 7 (#$ . 13947)]) (byte-code "\300\301\302\303!\203\f\303\202 \304\"\207" [defalias persistent-scratch-buffer-narrowed-p fboundp buffer-narrowed-p #[0 "edZ\300 W\207" [buffer-size] 2 "Return non-nil if the current buffer is narrowed."]] 4) #@213 Get an object representing the current buffer save state. The returned object is printable and readable. The exact format is undocumented, but must be kept in sync with what `persistent-scratch-restore' expects. (defalias 'persistent-scratch--get-buffer-state #[0 "\303\304 \214~\210\305>\203\306 \202\307\310\311 T\")\312>\205,`\3131)\314 0\202+\210\315B\301>\2053 \316 \205A\317>\205AedB\312>\205N\n?\206N\320 &\207" [persistent-scratch-what-to-save major-mode transient-mark-mode vector buffer-name text-properties buffer-string buffer-substring-no-properties 1 buffer-size point (error) mark nil persistent-scratch-buffer-narrowed-p narrowing region-active-p] 8 (#$ . 14631)]) #@45 Copy the save file to the backup directory. (defalias 'persistent-scratch--update-backup #[0 "\205 \304\n \"\305\"\262\306\307\"\210\310\307\311\307\211&\266\202\207" [persistent-scratch-backup-directory persistent-scratch-save-file persistent-scratch-backup-file-name-format persistent-scratch--current-backup-time format-time-string expand-file-name make-directory t copy-file nil] 9 (#$ . 15336)]) #@164 Clean up old backups. It's done by calling `persistent-scratch-backup-filter' on a list of all files in the backup directory and deleting all returned file names. (defalias 'persistent-scratch--cleanup-backups #[0 "\2050\302!\303\304\211\305$\306\304\307\310\"\"\262 !\211\205,\211@\311P!\210A\266\202\202\262\266\202\207" [persistent-scratch-backup-directory persistent-scratch-backup-filter file-name-as-directory directory-files nil t delq mapcar #[257 "\211\300\235?\205\211\207" [("." "..")] 3 "\n\n(fn NAME)"] delete-file] 7 (#$ . 15754)]) (defvar persistent-scratch--autosave-timer nil) #@46 Turn `persistent-scratch-autosave-mode' off. (defalias 'persistent-scratch--turn-autosave-off #[0 "\301\302\303\"\210\205\304!\210\305\211\207" [persistent-scratch--autosave-timer remove-hook kill-emacs-hook persistent-scratch-save cancel-timer nil] 3 (#$ . 16370)]) #@45 Turn `persistent-scratch-autosave-mode' on. (defalias 'persistent-scratch--turn-autosave-on #[0 "\302\303\304\"\210\305\211\304#\262\211\207" [persistent-scratch-autosave-interval persistent-scratch--autosave-timer add-hook kill-emacs-hook persistent-scratch-save run-with-timer] 5 (#$ . 16648)]) (provide 'persistent-scratch)