commit 8cd975cebd588d5435fa2b333dba6c526e602933 (HEAD, refs/remotes/origin/master) Author: Karl Fogel Date: Sun Oct 2 19:47:27 2016 -0500 Document yank behavior in the right place * lisp/simple.el (yank): Document the handling of the `yank-handled-properties' and `yank-excluded-properties' variables, and the `yank-handler' text property. (yank-pop): Refer to `yank' now (bug#286) * lisp/subr.el (insert-for-yank): Refer to `yank' now. (insert-for-yank-1): Refer to `insert-for-yank' now. See this thread for discussion: https://lists.gnu.org/archive/html/emacs-devel/2016-09/threads.html#00329 From: Karl Fogel To: Emacs Devel Subject: Question about intended behavior of 'insert-for-yank-1'. Date: Mon, 12 Sep 2016 00:17:14 -0500 Message-ID: <874m5lr92d.fsf@red-bean.com> diff --git a/lisp/simple.el b/lisp/simple.el index dd253ae..70bd759 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -4775,9 +4775,9 @@ If N is negative, this is a more recent kill. The sequence of kills wraps around, so that after the oldest one comes the newest one. -When this command inserts killed text into the buffer, it honors -`yank-excluded-properties' and `yank-handler' as described in the -doc string for `insert-for-yank-1', which see." +This command honors the `yank-handled-properties' and +`yank-excluded-properties' variables, and the `yank-handler' text +property, in the way that `yank' does." (interactive "*p") (if (not (eq last-command 'yank)) (user-error "Previous command was not a yank")) @@ -4810,10 +4810,34 @@ at the end, and set mark at the beginning without activating it. With just \\[universal-argument] as argument, put point at beginning, and mark at end. With argument N, reinsert the Nth most recent kill. -When this command inserts text into the buffer, it honors the -`yank-handled-properties' and `yank-excluded-properties' -variables, and the `yank-handler' text property. See -`insert-for-yank-1' for details. +This command honors the `yank-handled-properties' and +`yank-excluded-properties' variables, and the `yank-handler' text +property, as described below. + +Properties listed in `yank-handled-properties' are processed, +then those listed in `yank-excluded-properties' are discarded. + +If STRING has a non-nil `yank-handler' property anywhere, the +normal insert behavior is altered, and instead, for each contiguous +segment of STRING that has a given value of the `yank-handler' +property, that value is used as follows: + +The value of a `yank-handler' property must be a list of one to four +elements, of the form (FUNCTION PARAM NOEXCLUDE UNDO). +FUNCTION, if non-nil, should be a function of one argument (the + object to insert); FUNCTION is called instead of `insert'. +PARAM, if present and non-nil, is passed to FUNCTION (to be handled + in whatever way is appropriate; e.g. if FUNCTION is `yank-rectangle', + PARAM may be a list of strings to insert as a rectangle). If PARAM + is nil, then the current segment of STRING is used. +If NOEXCLUDE is present and non-nil, the normal removal of + `yank-excluded-properties' is not performed; instead FUNCTION is + responsible for the removal. This may be necessary if FUNCTION + adjusts point before or after inserting the object. +UNDO, if present and non-nil, should be a function to be called + by `yank-pop' to undo the insertion of the current PARAM. It is + given two arguments, the start and end of the region. FUNCTION + may set `yank-undo-function' to override UNDO. See also the command `yank-pop' (\\[yank-pop])." (interactive "*P") diff --git a/lisp/subr.el b/lisp/subr.el index e913e37..b143812 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -2893,9 +2893,11 @@ remove properties specified by `yank-excluded-properties'." (defvar yank-undo-function) (defun insert-for-yank (string) - "Call `insert-for-yank-1' repetitively for each `yank-handler' segment. + "Insert STRING at point for the `yank' command. -See `insert-for-yank-1' for more details." +This function is like `insert', except it honors the variables +`yank-handled-properties' and `yank-excluded-properties', and the +`yank-handler' text property, in the way that `yank' does." (let (to) (while (setq to (next-single-property-change 0 'yank-handler string)) (insert-for-yank-1 (substring string 0 to)) @@ -2903,31 +2905,7 @@ See `insert-for-yank-1' for more details." (insert-for-yank-1 string)) (defun insert-for-yank-1 (string) - "Insert STRING at point for the `yank' command. -This function is like `insert', except it honors the variables -`yank-handled-properties' and `yank-excluded-properties', and the -`yank-handler' text property. - -Properties listed in `yank-handled-properties' are processed, -then those listed in `yank-excluded-properties' are discarded. - -If STRING has a non-nil `yank-handler' property on its first -character, the normal insert behavior is altered. The value of -the `yank-handler' property must be a list of one to four -elements, of the form (FUNCTION PARAM NOEXCLUDE UNDO). -FUNCTION, if non-nil, should be a function of one argument, an - object to insert; it is called instead of `insert'. -PARAM, if present and non-nil, replaces STRING as the argument to - FUNCTION or `insert'; e.g. if FUNCTION is `yank-rectangle', PARAM - may be a list of strings to insert as a rectangle. -If NOEXCLUDE is present and non-nil, the normal removal of - `yank-excluded-properties' is not performed; instead FUNCTION is - responsible for the removal. This may be necessary if FUNCTION - adjusts point before or after inserting the object. -UNDO, if present and non-nil, should be a function to be called - by `yank-pop' to undo the insertion of the current object. It is - given two arguments, the start and end of the region. FUNCTION - may set `yank-undo-function' to override UNDO." + "Helper for `insert-for-yank', which see." (let* ((handler (and (stringp string) (get-text-property 0 'yank-handler string))) (param (or (nth 1 handler) string)) commit 2dfa3301690d6da4e278e9e170b16ad385d4d09e Author: Philipp Stephani Date: Sun Oct 2 22:19:08 2016 +0200 ; Fix build by reordering definitions diff --git a/lisp/frame.el b/lisp/frame.el index ab3b722..1c796be 100644 --- a/lisp/frame.el +++ b/lisp/frame.el @@ -2021,6 +2021,15 @@ widths." ;; Blinking cursor +(defvar blink-cursor-idle-timer nil + "Timer started after `blink-cursor-delay' seconds of Emacs idle time. +The function `blink-cursor-start' is called when the timer fires.") + +(defvar blink-cursor-timer nil + "Timer started from `blink-cursor-start'. +This timer calls `blink-cursor-timer-function' every +`blink-cursor-interval' seconds.") + (defgroup cursor nil "Displaying text cursors." :version "21.1" @@ -2052,15 +2061,6 @@ Use 0 or negative value to blink forever." (defvar blink-cursor-blinks-done 1 "Number of blinks done since we started blinking on NS, X, and MS-Windows.") -(defvar blink-cursor-idle-timer nil - "Timer started after `blink-cursor-delay' seconds of Emacs idle time. -The function `blink-cursor-start' is called when the timer fires.") - -(defvar blink-cursor-timer nil - "Timer started from `blink-cursor-start'. -This timer calls `blink-cursor-timer-function' every -`blink-cursor-interval' seconds.") - (defun blink-cursor--start-idle-timer () "Start the `blink-cursor-idle-timer'." (when blink-cursor-idle-timer (cancel-timer blink-cursor-idle-timer)) commit e0ac09906b68a6d96466fd12faf45a6e94f9ebbf Author: Philipp Stephani Date: Sat Sep 10 10:16:32 2016 +0200 Restart blink cursor timers on interval changes This prevents surprising behavior when timer interval customizations are only applied whenever the timers happen to be restarted (see Bug#24372). * lisp/frame.el (blink-cursor--start-idle-timer) (blink-cursor--start-timer): New functions. (blink-cursor-start, blink-cursor-check, blink-cursor-mode): Use the new helper functions. (blink-cursor-delay, blink-cursor-interval): Restart timers when the value is changed. diff --git a/lisp/frame.el b/lisp/frame.el index d3b6353..ab3b722 100644 --- a/lisp/frame.el +++ b/lisp/frame.el @@ -2029,12 +2029,18 @@ widths." (defcustom blink-cursor-delay 0.5 "Seconds of idle time after which cursor starts to blink." :type 'number - :group 'cursor) + :group 'cursor + :set (lambda (symbol value) + (set-default symbol value) + (when blink-cursor-idle-timer (blink-cursor--start-idle-timer)))) (defcustom blink-cursor-interval 0.5 "Length of cursor blink interval in seconds." :type 'number - :group 'cursor) + :group 'cursor + :set (lambda (symbol value) + (set-default symbol value) + (when blink-cursor-timer (blink-cursor--start-timer)))) (defcustom blink-cursor-blinks 10 "How many times to blink before using a solid cursor on NS, X, and MS-Windows. @@ -2055,6 +2061,24 @@ The function `blink-cursor-start' is called when the timer fires.") This timer calls `blink-cursor-timer-function' every `blink-cursor-interval' seconds.") +(defun blink-cursor--start-idle-timer () + "Start the `blink-cursor-idle-timer'." + (when blink-cursor-idle-timer (cancel-timer blink-cursor-idle-timer)) + (setq blink-cursor-idle-timer + ;; The 0.2 sec limitation from below is to avoid erratic + ;; behavior (or downright failure to display the cursor + ;; during command execution) if they set blink-cursor-delay + ;; to a very small or even zero value. + (run-with-idle-timer (max 0.2 blink-cursor-delay) + :repeat #'blink-cursor-start))) + +(defun blink-cursor--start-timer () + "Start the `blink-cursor-timer'." + (when blink-cursor-timer (cancel-timer blink-cursor-timer)) + (setq blink-cursor-timer + (run-with-timer blink-cursor-interval blink-cursor-interval + #'blink-cursor-timer-function))) + (defun blink-cursor-start () "Timer function called from the timer `blink-cursor-idle-timer'. This starts the timer `blink-cursor-timer', which makes the cursor blink @@ -2064,9 +2088,7 @@ command starts, by installing a pre-command hook." ;; Set up the timer first, so that if this signals an error, ;; blink-cursor-end is not added to pre-command-hook. (setq blink-cursor-blinks-done 1) - (setq blink-cursor-timer - (run-with-timer blink-cursor-interval blink-cursor-interval - 'blink-cursor-timer-function)) + (blink-cursor--start-timer) (add-hook 'pre-command-hook 'blink-cursor-end) (internal-show-cursor nil nil))) @@ -2113,13 +2135,7 @@ This is done when a frame gets focus. Blink timers may be stopped by (when (and blink-cursor-mode (not blink-cursor-idle-timer)) (remove-hook 'post-command-hook 'blink-cursor-check) - (setq blink-cursor-idle-timer - ;; The 0.2 sec limitation from below is to avoid erratic - ;; behavior (or downright failure to display the cursor - ;; during command execution) if they set blink-cursor-delay - ;; to a very small or even zero value. - (run-with-idle-timer (max 0.2 blink-cursor-delay) - :repeat #'blink-cursor-start)))) + (blink-cursor--start-idle-timer))) (define-obsolete-variable-alias 'blink-cursor 'blink-cursor-mode "22.1") @@ -2150,13 +2166,8 @@ terminals, cursor blinking is controlled by the terminal." (when blink-cursor-mode (add-hook 'focus-in-hook #'blink-cursor-check) (add-hook 'focus-out-hook #'blink-cursor-suspend) - (setq blink-cursor-idle-timer - ;; The 0.2 sec limitation from below is to avoid erratic - ;; behavior (or downright failure to display the cursor - ;; during command execution) if they set blink-cursor-delay - ;; to a very small or even zero value. - (run-with-idle-timer (max 0.2 blink-cursor-delay) - :repeat #'blink-cursor-start)))) + (blink-cursor--start-idle-timer))) + ;; Frame maximization/fullscreen commit 08b386db1f4212ce90f726442fcf356885fb31ae Author: Philipp Stephani Date: Sat Oct 1 20:13:53 2016 +0200 Use a simple keyword for a non-nil argument The second argument of `run-with-idle-timer' is Boolean, i.e. only nil and non-nil values are distinguished. Passing a number here is confusing. Pass a descriptive symbol instead. * lisp/frame.el (blink-cursor-mode, blink-cursor-check): Use :repeat symbol instead of number for second argument of `run-with-idle-timer' diff --git a/lisp/frame.el b/lisp/frame.el index b13621a..d3b6353 100644 --- a/lisp/frame.el +++ b/lisp/frame.el @@ -2119,8 +2119,7 @@ This is done when a frame gets focus. Blink timers may be stopped by ;; during command execution) if they set blink-cursor-delay ;; to a very small or even zero value. (run-with-idle-timer (max 0.2 blink-cursor-delay) - blink-cursor-delay - 'blink-cursor-start)))) + :repeat #'blink-cursor-start)))) (define-obsolete-variable-alias 'blink-cursor 'blink-cursor-mode "22.1") @@ -2157,8 +2156,7 @@ terminals, cursor blinking is controlled by the terminal." ;; during command execution) if they set blink-cursor-delay ;; to a very small or even zero value. (run-with-idle-timer (max 0.2 blink-cursor-delay) - blink-cursor-delay - #'blink-cursor-start)))) + :repeat #'blink-cursor-start)))) ;; Frame maximization/fullscreen