diff options
| author | Richard M. Stallman | 2005-03-29 20:53:19 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 2005-03-29 20:53:19 +0000 |
| commit | 7fcce20f6949bffc680fd8bd828344fdf04b5748 (patch) | |
| tree | f8c1b6d6d9b5f4585ddbda186300604f3bc04b12 | |
| parent | cf6ffd8c178cb6b8c8931ec1093f1d66d4b64a73 (diff) | |
| download | emacs-7fcce20f6949bffc680fd8bd828344fdf04b5748.tar.gz emacs-7fcce20f6949bffc680fd8bd828344fdf04b5748.zip | |
(idle-update-delay): Move definition up.
(buffer-substring-filters): New variable.
(filter-buffer-substring): New function.
(kill-region, copy-region-as-kill): Use it.
| -rw-r--r-- | lisp/simple.el | 57 |
1 files changed, 46 insertions, 11 deletions
diff --git a/lisp/simple.el b/lisp/simple.el index 95b519cf5ca..4d1369ddeda 100644 --- a/lisp/simple.el +++ b/lisp/simple.el | |||
| @@ -35,6 +35,13 @@ | |||
| 35 | (autoload 'widget-convert "wid-edit") | 35 | (autoload 'widget-convert "wid-edit") |
| 36 | (autoload 'shell-mode "shell")) | 36 | (autoload 'shell-mode "shell")) |
| 37 | 37 | ||
| 38 | (defcustom idle-update-delay 0.5 | ||
| 39 | "*Idle time delay before updating various things on the screen. | ||
| 40 | Various Emacs features that update auxiliary information when point moves | ||
| 41 | wait this many seconds after Emacs becomes idle before doing an update." | ||
| 42 | :type 'number | ||
| 43 | :group 'display | ||
| 44 | :version "22.1") | ||
| 38 | 45 | ||
| 39 | (defgroup killing nil | 46 | (defgroup killing nil |
| 40 | "Killing and yanking commands." | 47 | "Killing and yanking commands." |
| @@ -2218,6 +2225,42 @@ These commands include \\[set-mark-command] and \\[start-kbd-macro]." | |||
| 2218 | (reset-this-command-lengths) | 2225 | (reset-this-command-lengths) |
| 2219 | (restore-overriding-map)) | 2226 | (restore-overriding-map)) |
| 2220 | 2227 | ||
| 2228 | (defvar buffer-substring-filters nil | ||
| 2229 | "List of filter functions for `filter-buffer-substring'. | ||
| 2230 | Each function must accept a single argument, a string, and return | ||
| 2231 | a string. The buffer substring is passed to the first function | ||
| 2232 | in the list, and the return value of each function is passed to | ||
| 2233 | the next. The return value of the last function is used as the | ||
| 2234 | return value of `filter-buffer-substring'. | ||
| 2235 | |||
| 2236 | If this variable is nil, no filtering is performed.") | ||
| 2237 | |||
| 2238 | (defun filter-buffer-substring (beg end &optional delete) | ||
| 2239 | "Return the buffer substring between BEG and END, after filtering. | ||
| 2240 | The buffer substring is passed through each of the filter | ||
| 2241 | functions in `buffer-substring-filters', and the value from the | ||
| 2242 | last filter function is returned. If `buffer-substring-filters' | ||
| 2243 | is nil, the buffer substring is returned unaltered. | ||
| 2244 | |||
| 2245 | If DELETE is non-nil, the text between BEG and END is deleted | ||
| 2246 | from the buffer. | ||
| 2247 | |||
| 2248 | Point is temporarily set to BEG before caling | ||
| 2249 | `buffer-substring-filters', in case the functions need to know | ||
| 2250 | where the text came from. | ||
| 2251 | |||
| 2252 | This function should be used instead of `buffer-substring' or | ||
| 2253 | `delete-and-extract-region' when you want to allow filtering to | ||
| 2254 | take place. For example, major or minor modes can use | ||
| 2255 | `buffer-substring-filters' to extract characters that are special | ||
| 2256 | to a buffer, and should not be copied into other buffers." | ||
| 2257 | (save-excursion | ||
| 2258 | (goto-char beg) | ||
| 2259 | (let ((string (if delete (delete-and-extract-region beg end) | ||
| 2260 | (buffer-substring beg end)))) | ||
| 2261 | (dolist (filter buffer-substring-filters string) | ||
| 2262 | (setq string (funcall filter string)))))) | ||
| 2263 | |||
| 2221 | ;;;; Window system cut and paste hooks. | 2264 | ;;;; Window system cut and paste hooks. |
| 2222 | 2265 | ||
| 2223 | (defvar interprogram-cut-function nil | 2266 | (defvar interprogram-cut-function nil |
| @@ -2394,7 +2437,7 @@ specifies the yank-handler text property to be set on the killed | |||
| 2394 | text. See `insert-for-yank'." | 2437 | text. See `insert-for-yank'." |
| 2395 | (interactive "r") | 2438 | (interactive "r") |
| 2396 | (condition-case nil | 2439 | (condition-case nil |
| 2397 | (let ((string (delete-and-extract-region beg end))) | 2440 | (let ((string (filter-buffer-substring beg end t))) |
| 2398 | (when string ;STRING is nil if BEG = END | 2441 | (when string ;STRING is nil if BEG = END |
| 2399 | ;; Add that string to the kill ring, one way or another. | 2442 | ;; Add that string to the kill ring, one way or another. |
| 2400 | (if (eq last-command 'kill-region) | 2443 | (if (eq last-command 'kill-region) |
| @@ -2430,8 +2473,8 @@ If `interprogram-cut-function' is non-nil, also save the text for a window | |||
| 2430 | system cut and paste." | 2473 | system cut and paste." |
| 2431 | (interactive "r") | 2474 | (interactive "r") |
| 2432 | (if (eq last-command 'kill-region) | 2475 | (if (eq last-command 'kill-region) |
| 2433 | (kill-append (buffer-substring beg end) (< end beg)) | 2476 | (kill-append (filter-buffer-substring beg end) (< end beg)) |
| 2434 | (kill-new (buffer-substring beg end))) | 2477 | (kill-new (filter-buffer-substring beg end))) |
| 2435 | (if transient-mark-mode | 2478 | (if transient-mark-mode |
| 2436 | (setq deactivate-mark t)) | 2479 | (setq deactivate-mark t)) |
| 2437 | nil) | 2480 | nil) |
| @@ -5184,14 +5227,6 @@ See also `normal-erase-is-backspace'." | |||
| 5184 | (message "Delete key deletes %s" | 5227 | (message "Delete key deletes %s" |
| 5185 | (if normal-erase-is-backspace "forward" "backward")))) | 5228 | (if normal-erase-is-backspace "forward" "backward")))) |
| 5186 | 5229 | ||
| 5187 | (defcustom idle-update-delay 0.5 | ||
| 5188 | "*Idle time delay before updating various things on the screen. | ||
| 5189 | Various Emacs features that update auxiliary information when point moves | ||
| 5190 | wait this many seconds after Emacs becomes idle before doing an update." | ||
| 5191 | :type 'number | ||
| 5192 | :group 'display | ||
| 5193 | :version "22.1") | ||
| 5194 | |||
| 5195 | (defvar vis-mode-saved-buffer-invisibility-spec nil | 5230 | (defvar vis-mode-saved-buffer-invisibility-spec nil |
| 5196 | "Saved value of `buffer-invisibility-spec' when Visible mode is on.") | 5231 | "Saved value of `buffer-invisibility-spec' when Visible mode is on.") |
| 5197 | 5232 | ||