Customize extra chars for avy-goto-subword-1

* avy.el (avy-subword-extra-word-chars): New defcustom.
(avy-goto-subword-0): Modify the syntax table temporarily using
`avy-subword-extra-word-chars'.

Fixes #116
This commit is contained in:
Oleh Krehel 2015-12-07 14:54:16 +01:00
parent fa6d1e1242
commit b1a1953e1c

11
avy.el
View File

@ -955,6 +955,11 @@ The window scope is determined by `avy-all-windows' (ARG negates it)."
(declare-function subword-backward "subword") (declare-function subword-backward "subword")
(defvar subword-backward-regexp) (defvar subword-backward-regexp)
(defcustom avy-subword-extra-word-chars '(?{ ?= ?} ?* ?: ?> ?<)
"A list of characters that should temporarily match \"\\w\".
This variable is used by `avy-goto-subword-0' and `avy-goto-subword-1'."
:type '(repeat character))
;;;###autoload ;;;###autoload
(defun avy-goto-subword-0 (&optional arg predicate) (defun avy-goto-subword-0 (&optional arg predicate)
"Jump to a word or subword start. "Jump to a word or subword start.
@ -971,6 +976,10 @@ should return true."
"\\(\\(\\W\\|[[:lower:][:digit:]]\\)\\([!-/:@`~[:upper:]]+\\W*\\)\\|\\W\\w+\\)") "\\(\\(\\W\\|[[:lower:][:digit:]]\\)\\([!-/:@`~[:upper:]]+\\W*\\)\\|\\W\\w+\\)")
candidates) candidates)
(avy-dowindows arg (avy-dowindows arg
(let ((syn-tbl (copy-syntax-table)))
(dolist (char avy-subword-extra-word-chars)
(modify-syntax-entry char "w" syn-tbl))
(with-syntax-table syn-tbl
(let ((ws (window-start)) (let ((ws (window-start))
window-cands) window-cands)
(save-excursion (save-excursion
@ -982,7 +991,7 @@ should return true."
(unless (get-char-property (point) 'invisible) (unless (get-char-property (point) 'invisible)
(push (cons (point) (selected-window)) window-cands))) (push (cons (point) (selected-window)) window-cands)))
(subword-backward))) (subword-backward)))
(setq candidates (nconc candidates window-cands)))) (setq candidates (nconc candidates window-cands))))))
(avy--process candidates (avy--style-fn avy-style))))) (avy--process candidates (avy--style-fn avy-style)))))
;;;###autoload ;;;###autoload