Files
emacsd/elpa/edit-indirect-20191103.1013/edit-indirect.elc

153 lines
12 KiB
Plaintext
Raw Normal View History

2019-12-01 19:55:19 +01:00
;ELC
;;; Compiled
;;; in Emacs version 26.3
;;; with all optimizations.
;;; This file uses dynamic docstrings, first added in Emacs 19.29.
;;; This file does not contain utf-8 non-ASCII characters,
;;; and so can be loaded in Emacs versions earlier than 23.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(byte-code "\300\301\302\303\304\305%\210\306\307\310\311\312DD\313\314\311\304\301&\210\306\315\310\311\316DD\317\314\320\304\301&\210\306\321\310\311\322DD\323\314\320\304\301&\210\306\324\310\311\325DD\326\314\320\304\301&\210\306\327\310\311\330DD\331\314\320\304\301&\210\300\332\302\333\304\301\304\334\335\336& \210\337\340\341\342\304\332%\210\343\344N\345\211\346\347#\210\211\350\351#\210\211\352\353#\266\207" [custom-declare-group edit-indirect nil "Editing regions in separate buffers." :group editing custom-declare-variable edit-indirect-guess-mode-function funcall function #[0 "\300\207" [edit-indirect-default-guess-mode] 1] "The function used to guess the major mode of an edit-indirect buffer.\nIt's called with the edit-indirect buffer as the current buffer.\nIt's called with three arguments, the parent buffer, the beginning\nand the end of the parent buffer region being editing.\n\nNote that the buffer-local value from the parent buffer is used." :type edit-indirect-after-creation-hook #[0 "\300\207" [nil] 1] "Functions called after the edit-indirect buffer is created.\nThe functions are called with the edit-indirect buffer as the\ncurrent buffer.\n\nNote that the buffer-local value from the parent buffer is used." hook edit-indirect-before-commit-hook #[0 "\300\207" [nil] 1] "Functions called before the edit-indirect buffer is committed.\nThe functions are called with the edit-indirect buffer as the\ncurrent buffer.\n\nNote that the buffer-local value from the edit-indirect buffer is\nused." edit-indirect-before-commit-functions #[0 "\300\207" [nil] 1] "Functions called before an edit-indirect buffer is committed.\nThe functions are called with the parent buffer as the current\nbuffer.\nEach function is called with two arguments, the beginning and the\nend of the region to be changed." edit-indirect-after-commit-functions #[0 "\300\207" [nil] 1] "Functions called after an edit-indirect buffer has been committed.\nThe functions are called with the parent buffer as the current\nbuffer.\nEach function is called with two arguments, the beginning and the\nend of the changed region." edit-indirect-faces "Faces used in `edit-indirect'." faces :prefix "edit-indirect" custom-declare-face edit-indirect-edited-region ((t :inherit secondary-selection)) "Face used to highlight an indirectly edited region." user-error error-conditions #[771 "\300\301B#\210\300\302#\207" [put error-conditions error-message] 8 "\n\n(fn USER-ERROR-CONDITIONS NAME MESSAGE)"] edit-indirect-overlapping "Indirectly edited regions cannot overlap" edit-indirect-read-only "Text is read-only, modify the edit-indirect buffer instead" edit-indirect-not-indirect "This is not an edit-indirect buffer"] 10)
(defvar edit-indirect--should-quit-window nil)
#@1230 Edit the region BEG..END in a separate buffer.
The region is copied, without text properties, to a separate
buffer, called edit-indirect buffer, and
`edit-indirect-guess-mode-function' is called to set the major
mode.
When done, exit with `edit-indirect-commit', which will remove the
original region and replace it with the edited version; or with
`edit-indirect-abort', which will drop the modifications.
This differs from `clone-indirect-buffer' with narrowing in that
the text properties are not shared, so the parent buffer major mode
and the edit-indirect buffer major mode will not be able to tread
on each other's toes by setting up potentially conflicting text
properties, which happens surprisingly often when the font-lock
mode is used.
Edit-indirect buffers use the `edit-indirect-mode-map' keymap.
If there's already an edit-indirect buffer for BEG..END, use that.
If there's already an edit-indirect buffer active overlapping any
portion of BEG..END, an `edit-indirect-overlapping' error is
signaled.
When DISPLAY-BUFFER is non-nil or when called interactively,
display the edit-indirect buffer in some window and select it.
In any case, return the edit-indirect buffer.
(fn BEG END &optional DISPLAY-BUFFER)
(defalias 'edit-indirect-region #[770 "\301\"\203r\211q\210\302\300!\210\303)\304\305!!\210\211\207" [edit-indirect--should-quit-window edit-indirect--get-edit-indirect-buffer make-local-variable t select-window display-buffer] 7 (#$ . 3194) (byte-code "\301 \204 \204\302 \303 \304E\305 \210\207\306\307!\207" [transient-mark-mode use-region-p region-beginning region-end t deactivate-mark user-error "No region"] 3)])
#@62 Keymap for edit-indirect buffers.
\{edit-indirect-mode-map}
(defvar edit-indirect-mode-map (byte-code "\300 \301\302\303#\210\301\304\305#\210\301\306\305#\210\301\307\310#\210\211\207" [make-sparse-keymap define-key "" edit-indirect-save "'" edit-indirect-commit "" " " edit-indirect-abort] 5) (#$ . 4860))
#@277 Commit the modifications done in an edit-indirect buffer.
That is, replace the original region in the parent buffer with the
contents of the edit-indirect buffer.
The edit-indirect buffer is then killed.
Can be called only when the current buffer is an edit-indirect
buffer.
(defalias 'edit-indirect-commit #[0 "\300 \210\301 \210\302 \207" [edit-indirect--barf-if-not-indirect edit-indirect--commit edit-indirect--clean-up] 1 (#$ . 5186) nil])
#@234 Save the modifications done in an edit-indirect buffer.
That is, replace the original region in the parent buffer with the
contents of the edit-indirect buffer.
Can be called only when the current buffer is an edit-indirect
buffer.
(defalias 'edit-indirect-save #[0 "\300 \210\301 \207" [edit-indirect--barf-if-not-indirect edit-indirect--commit] 1 (#$ . 5639) nil])
#@139 Abort indirect editing in the current buffer and kill the buffer.
Can be called only when the current buffer is an edit-indirect
buffer.
(defalias 'edit-indirect-abort #[0 "\300 \210\301 \207" [edit-indirect--barf-if-not-indirect edit-indirect--abort] 1 (#$ . 6014) nil])
#@114 Non-nil iff the BUFFER is an edit-indirect buffer.
BUFFER defaults to the current buffer.
(fn &optional BUFFER)
(defalias 'edit-indirect-buffer-indirect-p #[256 "r\211\203\211q\210)??\207" [edit-indirect--overlay] 2 (#$ . 6294)])
#@115 Guess the major mode for an edit-indirect buffer.
It's done by calling `normal-mode'.
(fn PARENT-BUFFER BEG END)
(defalias 'edit-indirect-default-guess-mode #[771 "\300 \207" [normal-mode] 4 (#$ . 6535)])
#@156 The overlay spanning the region of the parent buffer being edited.
It's also used as the variable determining if we're in an
edit-indirect buffer at all.
(defvar edit-indirect--overlay nil (#$ . 6748))
(byte-code "\300\301!\210\302\301\303\304#\207" [make-variable-buffer-local edit-indirect--overlay put permanent-local t] 4)
#@120 Turn the `edit-indirect--mode' "minor mode" on.
OVERLAY is the value to set `edit-indirect--overlay' to.
(fn OVERLAY)
(defalias 'edit-indirect--mode #[257 "\211\301\302\303\304\305$\207" [edit-indirect--overlay add-hook kill-buffer-hook edit-indirect--abort-on-kill-buffer nil t] 6 (#$ . 7083)])
(add-minor-mode 'edit-indirect--overlay " indirect" edit-indirect-mode-map nil 'ignore)
#@208 Return an edit-indirect buffer for the region BEG..END.
If there's already an edit-indirect buffer active overlapping any
portion of BEG..END, an `edit-indirect-overlapping' error is
signaled.
(fn BEG END)
(defalias 'edit-indirect--get-edit-indirect-buffer #[514 "\300\"\211\204\301\"\302#\262\2021\303!U\203-\304!U\203-\305\306\"\2021\307\310\311\"\207" [edit-indirect--search-for-edit-indirect edit-indirect--create-overlay edit-indirect--create-indirect-buffer overlay-start overlay-end overlay-get edit-indirect-buffer signal edit-indirect-overlapping nil] 8 (#$ . 7476)])
#@157 Return an existing edit-indirect overlay for some region inside BEG..END.
If there's no indirectly edited region inside BEG..END, return
nil.
(fn BEG END)
(defalias 'edit-indirect--search-for-edit-indirect #[514 "\3002$\301\"\211\203!\211@\302\303\"\203\304\300\"\210A\266\202\202\210\3050\207" [done overlays-in overlay-get edit-indirect-buffer throw nil] 7 (#$ . 8080)])
#@91 Get the BUFFER local value of VARIABLE.
VARIABLE shall be a symbol.
(fn BUFFER VARIABLE)
(defalias 'edit-indirect--buffer-local-value '(macro . #[514 "\2119\204\f\300\301\302D\"\210\303E\207" [signal wrong-type-argument symbolp with-current-buffer] 6 (#$ . 8471)]))
#@172 Create an edit-indirect buffer and return it.
BEG..END is the parent buffer region to insert.
OVERLAY is the overlay, see `edit-indirect--overlay'.
(fn BEG END OVERLAY)
(defalias 'edit-indirect--create-indirect-buffer #[771 "\302\303\304\305 \"!p\306\307#\210rq\210\310#\210\311\312!\210\313!\210r\211q\210)#\210r\211q\210 )\314\301!\210*\207" [edit-indirect-guess-mode-function edit-indirect-after-creation-hook generate-new-buffer format "*edit-indirect %s*" buffer-name overlay-put edit-indirect-buffer insert-buffer-substring-no-properties set-buffer-modified-p nil edit-indirect--mode run-hooks] 9 (#$ . 8749)])
#@125 Create the edit-indirect overlay and return it.
BEG and END specify the region the overlay should encompass.
(fn BEG END)
(defalias 'edit-indirect--create-overlay #[514 "\300\"\301\302\303#\210\301\304\305#\210\301\306\307#\210\211\207" [make-overlay overlay-put face edit-indirect-edited-region modification-hooks (edit-indirect--barf-read-only) insert-in-front-hooks (edit-indirect--barf-read-only)] 7 (#$ . 9392)])
#@71 Non-nil means disregard read-only status of indirectly-edited region.
(defvar edit-indirect--inhibit-read-only nil (#$ . 9823))
#@179 Signal an error because the text is read-only.
No error is signaled if `inhibit-read-only' or
`edit-indirect--inhibit-read-only' is non-nil.
(fn OV AFTER BEG END &optional LEN)
(defalias 'edit-indirect--barf-read-only #[1284 "\206 ?\205 \302\303\304\"\207" [inhibit-read-only edit-indirect--inhibit-read-only signal edit-indirect-read-only nil] 8 (#$ . 9958)])
#@59 Commit the modifications done in an edit-indirect buffer.
(defalias 'edit-indirect--commit #[0 "\302\303!\210\304!\305!p\306r\307!q\210\212\310!\310!\311\312#\210\313 \314\315\316\317\320!\321\"\322$\216\323D!\210\324rq\210\325\326\327 T\")\306\211#\210)\210\311\330`#\210\331\211\223\210\211\331\211\223\266\202+\207" [edit-indirect--overlay edit-indirect--inhibit-read-only run-hooks edit-indirect-before-commit-hook overlay-start overlay-end t overlay-buffer copy-marker edit-indirect--run-hook-with-positions edit-indirect-before-commit-functions match-data make-byte-code 0 "\301\300\302\"\207" vconcat vector [set-match-data evaporate] 3 set-match-data replace-match buffer-substring-no-properties 1 buffer-size edit-indirect-after-commit-functions nil] 12 (#$ . 10330)])
#@257 Run HOOK with the specified positions BEG and END.
HOOK should be a symbol, a hook variable.
The functions are passed integer positions.
If a function changes the buffer contents, the next function will be
called with updated positions.
(fn HOOK BEG END)
(defalias 'edit-indirect--run-hook-with-positions #[771 "\300!?\205\n\301!\300!?\205\301!\302\303\206\206#$\210\203.\304\211\223\210\211\2056\211\304\211\223\207" [markerp copy-marker run-hook-wrapped #[771 "\300!\300!\"\210\301\207" [marker-position nil] 7 "\n\n(fn F BEG END)"] nil] 10 (#$ . 11129)])
#@22 Abort indirect edit.
(defalias 'edit-indirect--abort #[0 "\300 \207" [edit-indirect--clean-up] 1 (#$ . 11718)])
#@35 Clean up an edit-indirect buffer.
(defalias 'edit-indirect--clean-up #[0 "\302!\210\303 \203\304\305!\207\306 \207" [edit-indirect--overlay edit-indirect--should-quit-window delete-overlay nil quit-window t kill-buffer] 2 (#$ . 11836)])
#@69 Abort indirect edit.
Should be called only from `kill-buffer-hook'.
(defalias 'edit-indirect--abort-on-kill-buffer #[0 "\205\301 \207" [edit-indirect--overlay edit-indirect--abort] 1 (#$ . 12083)])
#@123 Signal an error if the current buffer is not an edit-indirect buffer.
The error signaled is `edit-indirect-not-indirect'.
(defalias 'edit-indirect--barf-if-not-indirect #[0 "?\205 \301\302\303\"\207" [edit-indirect--overlay signal edit-indirect-not-indirect nil] 3 (#$ . 12291)])
(provide 'edit-indirect)