branch: externals/expreg commit af897a63fb14f98c0e897e1ce09f052bc494ec87 Author: Yuan Fu <caso...@gmail.com> Commit: Yuan Fu <caso...@gmail.com>
Stricter condition for expreg-restore-point-on-quit (issue#8) * expreg.el (expreg--keyboard-quit-advice): Stricter condition. (expreg-expand): Use a marker instead. --- expreg.el | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/expreg.el b/expreg.el index ea7697dd94..68332ac713 100644 --- a/expreg.el +++ b/expreg.el @@ -229,7 +229,9 @@ This is used to restore point when canceling the expansion when (defun expreg--keyboard-quit-advice () "Restores point when ‘keyboard-quit’ is called." (interactive) - (when (and expreg-restore-point-on-quit expreg--initial-point) + (when (and expreg-restore-point-on-quit expreg--initial-point + (region-active-p) + (eq (marker-buffer expreg--initial-point) (current-buffer))) (goto-char expreg--initial-point)) (setq expreg--initial-point nil)) @@ -245,7 +247,7 @@ This is used to restore point when canceling the expansion when (cddr (car expreg--prev-regions))))) (setq-local expreg--next-regions nil) (setq-local expreg--prev-regions nil) - (setq-local expreg--initial-point (point)) + (setq-local expreg--initial-point (point-marker)) (when expreg-restore-point-on-quit ;; We have to add the advice using :before. :after doesn’t work ;; (advice doesn’t get called). ‘set-transient-map’ doesn’t work