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

:extend-selection nil does not work with evil-select-quote #708

Open
TheBB opened this issue Sep 2, 2016 · 0 comments
Open

:extend-selection nil does not work with evil-select-quote #708

TheBB opened this issue Sep 2, 2016 · 0 comments

Comments

@TheBB
Copy link
Member

TheBB commented Sep 2, 2016

Originally reported by: Sebastien Mondet (Bitbucket: smondet, GitHub: smondet)


When I try

(evil-define-text-object evil-a-double-quote-no-extend (count &optional beg end type)
  "Select a double-quoted expression."
  :extend-selection nil
  (evil-select-quote ?\" beg end type count t))

(define-key evil-outer-text-objects-map "\"" 'evil-a-double-quote-no-extend)

keys like va" still extend the selection to the whitespace around the quotes (I've checked it's indeed evil-a-double-quote-no-extend begin called).


It's “hard-coded” in the function evil-select-quote-thing:
evil-common.el:3258.

      ;; add whitespace
      (cond
       ((not inclusive) (setq beg (1+ beg) end (1- end)))
       ((not (eq inclusive 'quote-only))
        ;; try to add whitespace in forward direction
        (goto-char (if (> dir 0) end beg))
        (if (setq bnd (bounds-of-thing-at-point 'evil-space))
            (if (> dir 0) (setq end (cdr bnd)) (setq beg (car bnd)))
          ;; if not found try backward direction
          (goto-char (if (> dir 0) beg end))
          (if (and wsboth (setq bnd (bounds-of-thing-at-point 'evil-space)))
              (if (> dir 0) (setq beg (car bnd)) (setq end (cdr bnd)))))))

The second problem is that we cannot set the inclusive parameter to
'quote-only beacuse a bit earlier, the function overrides it loosing the
information:

      (if inclusive (setq inclusive t)
        (when (= (abs count) 2)
          (setq count dir)
          (setq inclusive 'quote-only))
        ;; never extend with exclusive selection
        (setq beg nil end nil))

By just replacing with this:

      (if inclusive (setq inclusive inclusive)

Then I can get this to work (extend-selection being just ignored):

(evil-define-text-object evil-a-double-quote-no-extend (count &optional beg end type)
  "Select a double-quoted expression."
  :extend-selection nil
  (evil-select-quote ?\" beg end type count 'quote-only))

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

No branches or pull requests

1 participant