diff options
-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 @@ +2012-08-16 Phil Sainty <psainty@orcon.net.nz> (tiny change) + + * 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. (Bug#11411) + 2012-08-15 Stefan Monnier <monnier@iro.umontreal.ca> * 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 @@ ;;; 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) |