diff options
| author | Phil Sainty | 2012-08-15 23:25:27 -0700 |
|---|---|---|
| committer | Glenn Morris | 2012-08-15 23:25:27 -0700 |
| commit | 1c308380b6f29e389dc10d418b9203a74d64dce2 (patch) | |
| tree | 12bd29c76d14d113a9d23bebfea2214ba055d398 /lisp | |
| parent | a098c9308eb2abee17d1f800d5895c12f471097e (diff) | |
| download | emacs-1c308380b6f29e389dc10d418b9203a74d64dce2.tar.gz emacs-1c308380b6f29e389dc10d418b9203a74d64dce2.zip | |
Make subword.el easier to customize (tiny change)
* lisp/progmodes/subword.el (subword-forward-function)
(subword-backward-function, subword-forward-regexp, subword-backward-regexp):
New variables.
(subword-forward, subword-forward-internal, subword-backward-internal):
Use new variables, eg so that different "word" definitions can be easily used.
Fixes: debbugs:11411
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/ChangeLog | 9 | ||||
| -rw-r--r-- | lisp/progmodes/subword.el | 28 |
2 files changed, 27 insertions, 10 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index cc42b1493ee..2202b4c7632 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,12 @@ | |||
| 1 | 2012-08-16 Phil Sainty <psainty@orcon.net.nz> (tiny change) | ||
| 2 | |||
| 3 | * progmodes/subword.el (subword-forward-function) | ||
| 4 | (subword-backward-function, subword-forward-regexp) | ||
| 5 | (subword-backward-regexp): New variables. | ||
| 6 | (subword-forward, subword-forward-internal, subword-backward-internal): | ||
| 7 | Use new variables, eg so that different "word" definitions | ||
| 8 | can be easily used. (Bug#11411) | ||
| 9 | |||
| 1 | 2012-08-15 Stefan Monnier <monnier@iro.umontreal.ca> | 10 | 2012-08-15 Stefan Monnier <monnier@iro.umontreal.ca> |
| 2 | 11 | ||
| 3 | * vc/vc-mtn.el (vc-mtn-revision-completion-table): Handle completion | 12 | * vc/vc-mtn.el (vc-mtn-revision-completion-table): Handle completion |
diff --git a/lisp/progmodes/subword.el b/lisp/progmodes/subword.el index 7d8dd4301a2..e541aed8867 100644 --- a/lisp/progmodes/subword.el +++ b/lisp/progmodes/subword.el | |||
| @@ -80,6 +80,20 @@ | |||
| 80 | 80 | ||
| 81 | ;;; Code: | 81 | ;;; Code: |
| 82 | 82 | ||
| 83 | (defvar subword-forward-function 'subword-forward-internal | ||
| 84 | "Function to call for forward subword movement.") | ||
| 85 | |||
| 86 | (defvar subword-backward-function 'subword-backward-internal | ||
| 87 | "Function to call for backward subword movement.") | ||
| 88 | |||
| 89 | (defvar subword-forward-regexp | ||
| 90 | "\\W*\\(\\([[:upper:]]*\\W?\\)[[:lower:][:digit:]]*\\)" | ||
| 91 | "Regexp used by `subword-forward-internal'.") | ||
| 92 | |||
| 93 | (defvar subword-backward-regexp | ||
| 94 | "\\(\\(\\W\\|[[:lower:][:digit:]]\\)\\([[:upper:]]+\\W*\\)\\|\\W\\w+\\)" | ||
| 95 | "Regexp used by `subword-backward-internal'.") | ||
| 96 | |||
| 83 | (defvar subword-mode-map | 97 | (defvar subword-mode-map |
| 84 | (let ((map (make-sparse-keymap))) | 98 | (let ((map (make-sparse-keymap))) |
| 85 | (dolist (cmd '(forward-word backward-word mark-word kill-word | 99 | (dolist (cmd '(forward-word backward-word mark-word kill-word |
| @@ -138,10 +152,10 @@ Optional argument ARG is the same as for `forward-word'." | |||
| 138 | (cond | 152 | (cond |
| 139 | ((< 0 arg) | 153 | ((< 0 arg) |
| 140 | (dotimes (i arg (point)) | 154 | (dotimes (i arg (point)) |
| 141 | (subword-forward-internal))) | 155 | (funcall subword-forward-function))) |
| 142 | ((> 0 arg) | 156 | ((> 0 arg) |
| 143 | (dotimes (i (- arg) (point)) | 157 | (dotimes (i (- arg) (point)) |
| 144 | (subword-backward-internal))) | 158 | (funcall subword-backward-function))) |
| 145 | (t | 159 | (t |
| 146 | (point)))) | 160 | (point)))) |
| 147 | 161 | ||
| @@ -249,9 +263,7 @@ Optional argument ARG is the same as for `capitalize-word'." | |||
| 249 | (if (and | 263 | (if (and |
| 250 | (save-excursion | 264 | (save-excursion |
| 251 | (let ((case-fold-search nil)) | 265 | (let ((case-fold-search nil)) |
| 252 | (re-search-forward | 266 | (re-search-forward subword-forward-regexp nil t))) |
| 253 | (concat "\\W*\\(\\([[:upper:]]*\\W?\\)[[:lower:][:digit:]]*\\)") | ||
| 254 | nil t))) | ||
| 255 | (> (match-end 0) (point))) | 267 | (> (match-end 0) (point))) |
| 256 | (goto-char | 268 | (goto-char |
| 257 | (cond | 269 | (cond |
| @@ -265,11 +277,7 @@ Optional argument ARG is the same as for `capitalize-word'." | |||
| 265 | (defun subword-backward-internal () | 277 | (defun subword-backward-internal () |
| 266 | (if (save-excursion | 278 | (if (save-excursion |
| 267 | (let ((case-fold-search nil)) | 279 | (let ((case-fold-search nil)) |
| 268 | (re-search-backward | 280 | (re-search-backward subword-backward-regexp nil t))) |
| 269 | (concat | ||
| 270 | "\\(\\(\\W\\|[[:lower:][:digit:]]\\)\\([[:upper:]]+\\W*\\)" | ||
| 271 | "\\|\\W\\w+\\)") | ||
| 272 | nil t))) | ||
| 273 | (goto-char | 281 | (goto-char |
| 274 | (cond | 282 | (cond |
| 275 | ((and (match-end 3) | 283 | ((and (match-end 3) |