summaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
Diffstat (limited to 'lisp')
-rw-r--r--lisp/emacs-lisp/cursor-sensor.el26
-rw-r--r--lisp/simple.el22
2 files changed, 37 insertions, 11 deletions
diff --git a/lisp/emacs-lisp/cursor-sensor.el b/lisp/emacs-lisp/cursor-sensor.el
index 7e3088dd91e..21c48f830f2 100644
--- a/lisp/emacs-lisp/cursor-sensor.el
+++ b/lisp/emacs-lisp/cursor-sensor.el
@@ -22,17 +22,29 @@
;;; Commentary:
-;; This package implements the `cursor-intangible' property, which is
-;; meant to replace the old `intangible' property. To use it, just enable the
-;; `cursor-intangible-mode', after which this package will move point away from
-;; any position that has a non-nil `cursor-intangible' property. This is only
-;; done just before redisplay happens, contrary to the old `intangible'
-;; property which was done at a much lower level.
+;; This package implements the `cursor-intangible' and
+;; `cursor-sensor-functions' properties, which are meant to replace
+;; the old `intangible', `point-entered', and `point-left' properties.
+
+;; To use `cursor-intangible', just enable the
+;; `cursor-intangible-mode' minor mode, after which this package will
+;; move point away from any position that has a non-nil
+;; `cursor-intangible' property. This is only done just before
+;; redisplay happens, contrary to the old `intangible' property which
+;; was done at a much lower level.
+
+;; To use `cursor-sensor-functions', enable the `cursor-sensor-mode'
+;; minor mode, after which the `cursor-sensor-functions' will be
+;; called just before redisplay happens, according to the movement of
+;; the cursor since the last redisplay.
;;; Code:
;;;###autoload
-(defvar cursor-sensor-inhibit nil)
+(defvar cursor-sensor-inhibit nil
+ "When non-nil, suspend `cursor-sensor-mode' and `cursor-intangible-mode'.
+By convention, this is a list of symbols where each symbol stands for the
+\"cause\" of the suspension.")
(defun cursor-sensor--intangible-p (pos)
(let ((p (get-pos-property pos 'cursor-intangible)))
diff --git a/lisp/simple.el b/lisp/simple.el
index db59b9f5bc3..6eb56b73c09 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -2172,7 +2172,11 @@ next element of the minibuffer history in the minibuffer."
(prompt-end (minibuffer-prompt-end))
(old-column (unless (and (eolp) (> (point) prompt-end))
(if (= (line-number-at-pos) 1)
- (max (- (current-column) (1- prompt-end)) 0)
+ (max (- (current-column)
+ (save-excursion
+ (goto-char (1- prompt-end))
+ (current-column)))
+ 0)
(current-column)))))
(condition-case nil
(with-no-warnings
@@ -2191,7 +2195,10 @@ next element of the minibuffer history in the minibuffer."
(goto-char (point-max))
(when old-column
(if (= (line-number-at-pos) 1)
- (move-to-column (+ old-column (1- (minibuffer-prompt-end))))
+ (move-to-column (+ old-column
+ (save-excursion
+ (goto-char (1- (minibuffer-prompt-end)))
+ (current-column))))
(move-to-column old-column)))))))
(defun previous-line-or-history-element (&optional arg)
@@ -2206,7 +2213,11 @@ previous element of the minibuffer history in the minibuffer."
(prompt-end (minibuffer-prompt-end))
(old-column (unless (and (eolp) (> (point) prompt-end))
(if (= (line-number-at-pos) 1)
- (max (- (current-column) (1- prompt-end)) 0)
+ (max (- (current-column)
+ (save-excursion
+ (goto-char (1- prompt-end))
+ (current-column)))
+ 0)
(current-column)))))
(condition-case nil
(with-no-warnings
@@ -2225,7 +2236,10 @@ previous element of the minibuffer history in the minibuffer."
(goto-char (minibuffer-prompt-end))
(if old-column
(if (= (line-number-at-pos) 1)
- (move-to-column (+ old-column (1- (minibuffer-prompt-end))))
+ (move-to-column (+ old-column
+ (save-excursion
+ (goto-char (1- (minibuffer-prompt-end)))
+ (current-column))))
(move-to-column old-column))
;; Put the cursor at the end of the visual line instead of the
;; logical line, so the next `previous-line-or-history-element'