Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Helm mark functions do not move the cursor at the right column #1770

Closed
Ambrevar opened this issue May 13, 2017 · 7 comments
Closed

Helm mark functions do not move the cursor at the right column #1770

Ambrevar opened this issue May 13, 2017 · 7 comments

Comments

@Ambrevar
Copy link
Member

This is basically #709 which I believe was closed a bit early.

@thierryvolpiatto You said it is a detail, but there is a use case where the current behaviour is inconvenient.

Using standard Emacs, I can set a mark then move the cursor to create a selection. If only then I realize that the first mark is not at the right spot, I can rectify that with C-x C-x (exchange-point-and-mark).

Helm mark functions (e.g. helm-mark-or-exchange-rect) almost allows to do that, but the point is moved to the beginning of the column when exchanging point and mark.

This forces me to use two bindings (the original exchange-point-and-mark and helm-mark-or-exchange-rect for the general case) instead of one.

helm: 20170419.2242
OS: Arch Linux
Emacs: 25.2

thierryvolpiatto pushed a commit that referenced this issue May 13, 2017
* helm-ring.el (helm-mark-ring-get-candidates): Real is now a marker.
(helm-mark-ring-default-action): New.
(helm-source-mark-ring): Use it.
(helm-source-global-mark-ring): Use it.
(helm-global-mark-ring-get-candidates): Real is now a marker.
@thierryvolpiatto
Copy link
Member

thierryvolpiatto commented May 13, 2017 via email

@Ambrevar
Copy link
Member Author

Ambrevar commented May 13, 2017

Thanks!

Sorry for the confusion with helm-mark-or-exchange-rect, I forgot it was of my own:

(defun helm-mark-or-exchange-rect ()
  "Run `helm-all-mark-rings' or `rectangle-exchange-point-and-mark' if in rectangle-mark-mode."
  (interactive)
  (if rectangle-mark-mode
      (rectangle-exchange-point-and-mark)
    (helm-all-mark-rings)))

Let's forget that and use helm-all-mark-rings instead.

In terms of column position, it seems to work.
In terms of usability, it is still not quite superseding exchange-point-and-mark.

With exchange-point-and-mark:

  • Mark
  • Move the cursor to the desired position.
  • exchange-point-and-mark to fix the initial mark.

With helm-all-mark-rings:

  • Mark
  • Move the cursor to the desired position.
  • Mark again.
  • helm-all-mark-rings
  • select second entry and fix the initial mark.

The functions don't serve the same purpose, but I'm wondering if there is a way to supersede exchange-point-and-mark elegantly.

@Ambrevar
Copy link
Member Author

I found a solution that seems to work pretty well:

(defun helm-all-mark-rings-before-mark-point ()
  "Call `helm-all-mark-rings' before pushing the former point to the mark ring.
In Transcient Mark mode, this allows for rectifying the initial mark."
  (interactive)
  (let ((pos (point)) )
    (helm-all-mark-rings)
    (push-mark pos)))

The workflow is as follows:

  • Mark
  • Move the cursor to the desired position.
  • helm-all-mark-rings-before-mark-point
  • Confirm and fix the initial mark.

Compared to Emacs original behaviour, it is only one more key press.

@thierryvolpiatto
Copy link
Member

thierryvolpiatto commented May 13, 2017 via email

thierryvolpiatto pushed a commit that referenced this issue May 13, 2017
* helm-ring.el (helm-mark-ring-default-action): Do it, save helm-yank-point as
well and maybe cleanup overlays.
@thierryvolpiatto
Copy link
Member

thierryvolpiatto commented May 13, 2017 via email

@Ambrevar
Copy link
Member Author

Ambrevar commented May 13, 2017

The purpose of helm-mark-ring is to store visited positions to retrieve
them quickly, I still don't understand what you want to do with
exchange-point-and-mark.

Just that: using helm-mark-ring's functions to store point and then retrieving the last mark, thus effectively doing the same thing as exchange-point-and-mark.

If you want to save the new position why don't you hit C-space twice ?

Because as I detailed above, before commit b518c23 it was 1 more mark + 1 more selection in the helm buffer. Not convenient.

Note that all the helm search functions are saving position to mark-ring
when leaving this position, before this recent change helm-mark-ring was
doing this too we have to restore this, perhaps it is this that is
missing for you ?

Which recent change?

Anyways, this is exactly what was missing for me, it works well. Consider it solved!

@thierryvolpiatto
Copy link
Member

Great, closing now.

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants