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

Expanding versions of the thing selection commands #552

Open
chrisbouchard opened this issue Feb 6, 2024 · 2 comments
Open

Expanding versions of the thing selection commands #552

chrisbouchard opened this issue Feb 6, 2024 · 2 comments

Comments

@chrisbouchard
Copy link

I'd really like to see expanding versions of the current transient thing-based selection commands. For example, I'd like to be able to say . p ; ] p (or something) to select two paragraphs. Even nicer would be if I could type . p 5 (or something) to select the current paragraph and the next five.

Deleting large blocks of text is very painful without this feature.

@DogLooksGood
Copy link
Collaborator

You can just expand the selection with builtin forward-paragraph and backward-paragraph, . p M-} M-}. The same to the sentence.

@okamsn
Copy link
Contributor

okamsn commented Feb 13, 2024

Here is what I have been using, based on meow-beginning-of-thing and meow-end-of-thing:

  (defun my-meow-extend-to-end-of-thing (thing)
    "Extend selection to the end of THING."
    (interactive (list (meow-thing-prompt "Extend to end of: ")))
    (if (not (use-region-p))
        (meow-end-of-thing thing)
      (save-window-excursion
        (let ((back (equal 'backward (meow--thing-get-direction 'end)))
              (bounds (meow--parse-inner-of-thing-char thing)))
          (let ((beg (min (point) (mark))))
            (when bounds
              (thread-first
                (meow--make-selection '(select . transient)
                                      (if back (cdr bounds) beg)
                                      (if back beg (cdr bounds)))
                (meow--select))))))))

  (defun my-meow-extend-to-beginning-of-thing (thing)
    "Extend selection to the beginning of THING."
    (interactive (list (meow-thing-prompt "Extend to beginning of: ")))
    (if (not (use-region-p))
        (meow-beginning-of-thing thing)
      (save-window-excursion
        (let ((back (equal 'backward (meow--thing-get-direction 'beginning)))
              (bounds (meow--parse-inner-of-thing-char thing)))
          (let ((end (max (point) (mark))))
            (when bounds
              (thread-first
                (meow--make-selection '(select . transient)
                                      (if back end (car bounds))
                                      (if back (car bounds) end))
                (meow--select))))))))

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

3 participants