`:extend-selection nil` does not work with `evil-select-quote`
- Dominant language
- Emacs Lisp
- Stars
- 3.9k
- Forks
- 307
- PR merge metrics
- No merged PRs in 30d
Description
Originally reported by: **Sebastien Mondet (Bitbucket: [smondet](https://bitbucket.org/smondet), GitHub: [smondet](https://github.com/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`](https://bitbucket.org/lyro/evil/src/f2648b841f9bcded8764ce63410065d2b8c5f856/evil-common.el?at=default&fileviewer=file-view-default#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))
```
----------------------------------------
- Bitbucket: https://bitbucket.org/lyro/evil/issue/708
Contributor guide
Research direction
Start in evil-common.el around line 3258 and inspect evil-select-quote-thing, then reproduce the issue with the evil-define-text-object example in the report. Done means :extend-selection nil no longer adds surrounding whitespace and the 'quote-only value remains usable when passed as inclusive.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- emacs-lisp
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100