diff options
author | Phil Sainty <psainty@orcon.net.nz> | 2012-08-15 23:25:27 -0700 |
---|---|---|
committer | Glenn Morris <rgm@gnu.org> | 2012-08-15 23:25:27 -0700 |
commit | 1c308380b6f29e389dc10d418b9203a74d64dce2 (patch) | |
tree | 12bd29c76d14d113a9d23bebfea2214ba055d398 /lisp/progmodes/subword.el | |
parent | a098c9308eb2abee17d1f800d5895c12f471097e (diff) | |
download | emacs-1c308380b6f29e389dc10d418b9203a74d64dce2.tar.gz emacs-1c308380b6f29e389dc10d418b9203a74d64dce2.tar.bz2 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/progmodes/subword.el')
-rw-r--r-- | lisp/progmodes/subword.el | 28 |
1 files changed, 18 insertions, 10 deletions
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 @@ ;;; Code: +(defvar subword-forward-function 'subword-forward-internal + "Function to call for forward subword movement.") + +(defvar subword-backward-function 'subword-backward-internal + "Function to call for backward subword movement.") + +(defvar subword-forward-regexp + "\\W*\\(\\([[:upper:]]*\\W?\\)[[:lower:][:digit:]]*\\)" + "Regexp used by `subword-forward-internal'.") + +(defvar subword-backward-regexp + "\\(\\(\\W\\|[[:lower:][:digit:]]\\)\\([[:upper:]]+\\W*\\)\\|\\W\\w+\\)" + "Regexp used by `subword-backward-internal'.") + (defvar subword-mode-map (let ((map (make-sparse-keymap))) (dolist (cmd '(forward-word backward-word mark-word kill-word @@ -138,10 +152,10 @@ Optional argument ARG is the same as for `forward-word'." (cond ((< 0 arg) (dotimes (i arg (point)) - (subword-forward-internal))) + (funcall subword-forward-function))) ((> 0 arg) (dotimes (i (- arg) (point)) - (subword-backward-internal))) + (funcall subword-backward-function))) (t (point)))) @@ -249,9 +263,7 @@ Optional argument ARG is the same as for `capitalize-word'." (if (and (save-excursion (let ((case-fold-search nil)) - (re-search-forward - (concat "\\W*\\(\\([[:upper:]]*\\W?\\)[[:lower:][:digit:]]*\\)") - nil t))) + (re-search-forward subword-forward-regexp nil t))) (> (match-end 0) (point))) (goto-char (cond @@ -265,11 +277,7 @@ Optional argument ARG is the same as for `capitalize-word'." (defun subword-backward-internal () (if (save-excursion (let ((case-fold-search nil)) - (re-search-backward - (concat - "\\(\\(\\W\\|[[:lower:][:digit:]]\\)\\([[:upper:]]+\\W*\\)" - "\\|\\W\\w+\\)") - nil t))) + (re-search-backward subword-backward-regexp nil t))) (goto-char (cond ((and (match-end 3) |