Don't push mark as much #159

Open
Malabarba opened this Issue Mar 19, 2015 · 3 comments

Comments

Projects
None yet
3 participants
@Malabarba

(This is tested in latex and org-mode)

  1. Hit C-SPC a couple of times to make sure the mark is set somewhere.
  2. Move to a word somewhere else
  3. Hit er/expand-region once, then hit C-g.
  4. Try to pop-mark by hitting C-u C-SPC.

In my configuration I have to pop mark 8 times before I'm finally taken to the previous location. I understand er relies on altering the mark a lot, but there must be a way of restoring the mark ring to a previous state so that we are not left 8 identical entries.

Thanks for the great package!

@magnars

This comment has been minimized.

Show comment
Hide comment
@magnars

magnars Mar 19, 2015

Owner

Yeah, I've wanted to solve this issue, but never been able to do so in a good way.

This is some code from my emacs settings which alleviates the problem somewhat:

;; When popping the mark, continue popping until the cursor actually moves
;; Also, if the last command was a copy - skip past all the expand-region cruft.
(defadvice pop-to-mark-command (around ensure-new-position activate)
  (let ((p (point)))
    (when (eq last-command 'kill-ring-save)
      ad-do-it
      ad-do-it
      ad-do-it)
    (dotimes (i 10)
      (when (= p (point)) ad-do-it))))
Owner

magnars commented Mar 19, 2015

Yeah, I've wanted to solve this issue, but never been able to do so in a good way.

This is some code from my emacs settings which alleviates the problem somewhat:

;; When popping the mark, continue popping until the cursor actually moves
;; Also, if the last command was a copy - skip past all the expand-region cruft.
(defadvice pop-to-mark-command (around ensure-new-position activate)
  (let ((p (point)))
    (when (eq last-command 'kill-ring-save)
      ad-do-it
      ad-do-it
      ad-do-it)
    (dotimes (i 10)
      (when (= p (point)) ad-do-it))))
@Malabarba

This comment has been minimized.

Show comment
Hide comment
@Malabarba

Malabarba Mar 19, 2015

Thanks, that helps a lot.

Thanks, that helps a lot.

@catesandrew

This comment has been minimized.

Show comment
Hide comment
@catesandrew

catesandrew Feb 21, 2016

I use something similar from endless parentheses

(defun modi/multi-pop-to-mark (orig-fun &rest args)
  "Call ORIG-FUN until the cursor moves.
Try the repeated popping up to 10 times."
  (let ((p (point)))
    (dotimes (i 10)
      (when (= p (point))
        (apply orig-fun args)))))
(advice-add 'pop-to-mark-command :around
            #'modi/multi-pop-to-mark)

and set this (setq set-mark-command-repeat-pop t).

I use something similar from endless parentheses

(defun modi/multi-pop-to-mark (orig-fun &rest args)
  "Call ORIG-FUN until the cursor moves.
Try the repeated popping up to 10 times."
  (let ((p (point)))
    (dotimes (i 10)
      (when (= p (point))
        (apply orig-fun args)))))
(advice-add 'pop-to-mark-command :around
            #'modi/multi-pop-to-mark)

and set this (setq set-mark-command-repeat-pop t).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment