diff options
| author | Fabián Ezequiel Gallina | 2015-01-28 00:09:39 -0300 |
|---|---|---|
| committer | Fabián Ezequiel Gallina | 2015-01-28 00:09:39 -0300 |
| commit | 8e9166c92c97e7c2041eecee4e00d412a1eca1be (patch) | |
| tree | 41dc296808281e0883fcc3f70b4323fbad65b69c /lisp/progmodes | |
| parent | be2d23e58721b7acc68c0ea654a38e5109df2aa2 (diff) | |
| parent | a012c7bbca887c3da837ce3d7ec01be697cffe64 (diff) | |
| download | emacs-8e9166c92c97e7c2041eecee4e00d412a1eca1be.tar.gz emacs-8e9166c92c97e7c2041eecee4e00d412a1eca1be.zip | |
Merge from origin/emacs-24
a012c7b Fix copyright years by hand
732fd4c Update copyright year to 2015
Conflicts:
INSTALL.REPO
admin/notes/lel-TODO
doc/man/grep-changelog.1
doc/misc/eww.texi
etc/CONTRIBUTE
etc/GNU
etc/NEWS
etc/refcards/emacsver.tex
etc/refcards/ru-refcard.tex
lib-src/grep-changelog
lib-src/test-distrib.c
lib/alloca.in.h
lib/binary-io.h
lib/c-ctype.h
lib/c-strcasecmp.c
lib/c-strncasecmp.c
lib/careadlinkat.c
lib/close-stream.c
lib/dosname.h
lib/dup2.c
lib/filemode.h
lib/fpending.c
lib/fpending.h
lib/getgroups.c
lib/getloadavg.c
lib/getopt.in.h
lib/getopt1.c
lib/getopt_int.h
lib/gettext.h
lib/gettime.c
lib/gettimeofday.c
lib/group-member.c
lib/md5.c
lib/md5.h
lib/memrchr.c
lib/sha1.c
lib/sig2str.c
lib/stdarg.in.h
lib/stdbool.in.h
lib/stdlib.in.h
lib/strftime.c
lib/strtoimax.c
lib/strtol.c
lib/strtoll.c
lib/strtoull.c
lib/tempname.c
lib/time_r.c
lib/unsetenv.c
lib/xalloc-oversized.h
lisp/gnus/gnus-setup.el
lisp/progmodes/cap-words.el
lisp/w32-common-fns.el
m4/alloca.m4
m4/dup2.m4
m4/filemode.m4
m4/getgroups.m4
m4/getloadavg.m4
m4/gettime.m4
m4/gettimeofday.m4
m4/gnulib-common.m4
m4/group-member.m4
m4/manywarnings.m4
m4/memrchr.m4
m4/mktime.m4
m4/pathmax.m4
m4/pthread_sigmask.m4
m4/sig2str.m4
m4/ssize_t.m4
m4/st_dm_mode.m4
m4/stat-time.m4
m4/stdarg.m4
m4/stdbool.m4
m4/stddef_h.m4
m4/stdio_h.m4
m4/strftime.m4
m4/strtoimax.m4
m4/strtoll.m4
m4/strtoull.m4
m4/strtoumax.m4
m4/time_h.m4
m4/timer_time.m4
m4/timespec.m4
m4/unistd_h.m4
m4/utimbuf.m4
nextstep/README
nt/addsection.c
src/insdel.c
src/w32heap.c
test/automated/package-x-test.el
Diffstat (limited to 'lisp/progmodes')
| -rw-r--r-- | lisp/progmodes/cap-words.el | 98 |
1 files changed, 98 insertions, 0 deletions
diff --git a/lisp/progmodes/cap-words.el b/lisp/progmodes/cap-words.el new file mode 100644 index 00000000000..94e865db62b --- /dev/null +++ b/lisp/progmodes/cap-words.el | |||
| @@ -0,0 +1,98 @@ | |||
| 1 | ;;; cap-words.el --- minor mode for motion in CapitalizedWordIdentifiers | ||
| 2 | |||
| 3 | ;; Copyright (C) 2002-2015 Free Software Foundation, Inc. | ||
| 4 | |||
| 5 | ;; Author: Dave Love <fx@gnu.org> | ||
| 6 | ;; Keywords: languages | ||
| 7 | |||
| 8 | ;; This file is part of GNU Emacs. | ||
| 9 | |||
| 10 | ;; GNU Emacs is free software: you can redistribute it and/or modify | ||
| 11 | ;; it under the terms of the GNU General Public License as published by | ||
| 12 | ;; the Free Software Foundation, either version 3 of the License, or | ||
| 13 | ;; (at your option) any later version. | ||
| 14 | |||
| 15 | ;; GNU Emacs is distributed in the hope that it will be useful, | ||
| 16 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 17 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 18 | ;; GNU General Public License for more details. | ||
| 19 | |||
| 20 | ;; You should have received a copy of the GNU General Public License | ||
| 21 | ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. | ||
| 22 | |||
| 23 | ;;; Commentary: | ||
| 24 | |||
| 25 | ;; Provides Capitalized Words minor mode for word movement in | ||
| 26 | ;; identifiers CapitalizedLikeThis. | ||
| 27 | |||
| 28 | ;; Note that the same effect could be obtained by frobbing the | ||
| 29 | ;; category of upper case characters to produce word boundaries, but | ||
| 30 | ;; the necessary processing isn't done for ASCII characters. | ||
| 31 | |||
| 32 | ;; Fixme: This doesn't work properly for mouse double clicks. | ||
| 33 | |||
| 34 | ;;; Code: | ||
| 35 | |||
| 36 | (defun capitalized-find-word-boundary (pos limit) | ||
| 37 | "Function for use in `find-word-boundary-function-table'. | ||
| 38 | Looks for word boundaries before capitals." | ||
| 39 | (save-excursion | ||
| 40 | (goto-char pos) | ||
| 41 | (let (case-fold-search) | ||
| 42 | (if (<= pos limit) | ||
| 43 | ;; Fixme: Are these regexps the best? | ||
| 44 | (or (and (re-search-forward "\\=.\\w*[[:upper:]]" | ||
| 45 | limit t) | ||
| 46 | (progn (backward-char) | ||
| 47 | t)) | ||
| 48 | (re-search-forward "\\>" limit t)) | ||
| 49 | (or (re-search-backward "[[:upper:]]\\w*\\=" limit t) | ||
| 50 | (re-search-backward "\\<" limit t)))) | ||
| 51 | (point))) | ||
| 52 | |||
| 53 | |||
| 54 | (defconst capitalized-find-word-boundary-function-table | ||
| 55 | (let ((tab (make-char-table nil))) | ||
| 56 | (set-char-table-range tab t #'capitalized-find-word-boundary) | ||
| 57 | tab) | ||
| 58 | "Assigned to `find-word-boundary-function-table' in Capitalized Words mode.") | ||
| 59 | |||
| 60 | ;;;###autoload | ||
| 61 | (define-minor-mode capitalized-words-mode | ||
| 62 | "Toggle Capitalized Words mode. | ||
| 63 | With a prefix argument ARG, enable Capitalized Words mode if ARG | ||
| 64 | is positive, and disable it otherwise. If called from Lisp, | ||
| 65 | enable the mode if ARG is omitted or nil. | ||
| 66 | |||
| 67 | Capitalized Words mode is a buffer-local minor mode. When | ||
| 68 | enabled, a word boundary occurs immediately before an uppercase | ||
| 69 | letter in a symbol. This is in addition to all the normal | ||
| 70 | boundaries given by the syntax and category tables. There is no | ||
| 71 | restriction to ASCII. | ||
| 72 | |||
| 73 | E.g. the beginning of words in the following identifier are as marked: | ||
| 74 | |||
| 75 | capitalizedWorDD | ||
| 76 | ^ ^ ^^ | ||
| 77 | |||
| 78 | Note that these word boundaries only apply for word motion and | ||
| 79 | marking commands such as \\[forward-word]. This mode does not affect word | ||
| 80 | boundaries found by regexp matching (`\\>', `\\w' &c). | ||
| 81 | |||
| 82 | This style of identifiers is common in environments like Java ones, | ||
| 83 | where underscores aren't trendy enough. Capitalization rules are | ||
| 84 | sometimes part of the language, e.g. Haskell, which may thus encourage | ||
| 85 | such a style. It is appropriate to add `capitalized-words-mode' to | ||
| 86 | the mode hook for programming language modes in which you encounter | ||
| 87 | variables like this, e.g. `java-mode-hook'. It's unlikely to cause | ||
| 88 | trouble if such identifiers aren't used. | ||
| 89 | |||
| 90 | See also `glasses-mode' and `studlify-word'. | ||
| 91 | Obsoletes `c-forward-into-nomenclature'." | ||
| 92 | nil " Caps" nil :group 'programming | ||
| 93 | (set (make-local-variable 'find-word-boundary-function-table) | ||
| 94 | capitalized-find-word-boundary-function-table)) | ||
| 95 | |||
| 96 | (provide 'cap-words) | ||
| 97 | |||
| 98 | ;;; cap-words.el ends here | ||