bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#29097: 25.1; to support '_' as a word constituent, subword-mode rege


From: Chris Hecker
Subject: bug#29097: 25.1; to support '_' as a word constituent, subword-mode regexes need updating
Date: Tue, 31 Oct 2017 20:51:23 -0700
User-agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0


If you like using identifiers with underscores (_) in them, like
C macros or even just regular identifiers, you can add _ as a word
constituent in the syntax tables, but if you're using subword-mode
then the forward and backwards regexes need updating to work
correctly.  Here is the relevant section of my .emacs c-mode hook:

  (subword-mode 1)
  (modify-syntax-entry ?_ "w")
  (make-local-variable 'subword-forward-regexp)
  (setq subword-forward-regexp "\\W*\\(\\([[:upper:]]*_*\\(\\W\\)?\\)[[:lower:][:digit:]_]*\\)")
  (make-local-variable 'subword-backward-regexp)
  (setq subword-backward-regexp "\\(\\(\\W\\|[[:lower:][:digit:]_]\\)\\([[:upper:]]+\\(_*\\|\\W*\\)\\)\\|\\W\\w+\\)")

I've tested these with these code snippets and they work properly.

            TESTING
            ThisIs_A_Testy10Test
            ANOTHER__TEST_ThatIs_Weird
            case ui::GAME_ACCEPT_CANCEL:

They also work properly and as expected if you don't add _ to "w" (meaning comment out the
modify-syntax-table line above), so it seems like they are strictly superior to the current ones
and should replace them in subword.el?

Thanks,
Chris




In GNU Emacs 25.1.1 (x86_64-w64-mingw32)
 of 2016-11-15 built on LAPHROAIG
Windowing system distributor 'Microsoft Corp.', version 6.1.7601
Configured using:
 'configure --without-dbus --without-compress-install 'CFLAGS=-O2
 -static -g3''

Configured features:
XPM JPEG TIFF GIF PNG RSVG SOUND NOTIFY ACL GNUTLS LIBXML2 ZLIB
TOOLKIT_SCROLL_BARS

Important settings:
  value of $LANG: ENU
  locale-coding-system: cp1252

Major mode: C++/l

Minor modes in effect:
  diff-auto-refine-mode: t
  subword-mode: t
  minibuffer-depth-indicate-mode: t
  icicle-mode: t
  which-function-mode: t
  shell-dirtrack-mode: t
  global-eldoc-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  column-number-mode: t
  line-number-mode: t
  abbrev-mode: t

Recent messages:
Mark activated
Mark set [2 times]
next-line: End of buffer
Mark set [2 times]
Saving file c:/Users/checker/.emacs...
Wrote c:/Users/checker/.emacs
Type "q" to restore previous buffer, M-x scroll-up to scroll help.
Matching buffer contents...
checker-c-hook
Computing completion candidates... [3 times]

Load-path shadows:
~/emacs/lisp/json hides c:/apps/emacs/emacs-25.1-2/share/emacs/25.1/lisp/json
~/emacs/lisp/css-mode hides c:/apps/emacs/emacs-25.1-2/share/emacs/25.1/lisp/textmodes/css-mode

Features:
(shadow sort emacsbug iso-transl edebug thai-util thai-word calccomp
calc-alg calc-menu ruler-mode hl-line hexl debug warnings make-mode
calc-arith calc-bin tabify man vc-annotate log-view bat-mode log-edit
pcvs-util vc rect diff-mode align find-file dabbrev image-file mail-extr
eieio-opt speedbar sb-image ezimage dframe find-func ibuf-ext arc-mode
archive-mode misearch multi-isearch face-remap edmacro add-log
vc-dispatcher vc-bzr cap-words superword subword etags-select etags xref
project mb-depth two-column bookmark pp icicles icicles-mode
icicles-cmd2 easy-mmode icicles-cmd1 icicles-mcmd image-dired doremi
icicles-fn icicles-var icicles-opt kmacro ffap url-parse url-vars
cus-theme package seq hexrgb thingatpt icicles-face calc-vec calc-forms
calc-misc calc-aent calc-prog calc-ext calc calc-loaddefs calc-macs
mel-mode browse-url prop-mode pfx-mode message idna dired+ dired-aux
dired-x dired rfc822 mml mml-sec epg epg-config mm-decode mm-bodies
mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader smtpmail
sendmail rfc2047 rfc2045 ietf-drums mail-utils ibuffer ediff-merg
ediff-wind ediff-diff ediff-mult ediff-help ediff-init ediff-util ediff
caml-font 7z-arc-mode cperl-mode matlab derived tempo which-func imenu
cus-edit wid-edit grep cus-start cus-load cc-mode cc-fonts cc-guess
cc-menus cc-cmds cc-styles cc-align cc-engine cc-vars cc-defs compile
browse-kill-ring view checker-allout checker-outline hmac-sha1 tramp
tramp-compat auth-source cl-seq eieio byte-opt bytecomp byte-compile
cl-extra cconv eieio-core cl-macs gv gnus-util mm-util help-fns
help-mode cl-loaddefs pcase cl-lib mail-prsvr password-cache
tramp-loaddefs trampver ucs-normalize shell pcomplete comint ansi-color
ring format-spec advice tex-site server info easymenu time-date
mule-util tooltip eldoc electric uniquify ediff-hook vc-hooks
lisp-float-type mwheel dos-w32 ls-lisp disp-table w32-win w32-vars
term/common-win tool-bar dnd fontset image regexp-opt fringe
tabulated-list newcomment elisp-mode lisp-mode prog-mode register page
menu-bar rfn-eshadow timer select scroll-bar mouse jit-lock font-lock
syntax facemenu font-core frame cl-generic cham georgian utf-8-lang
misc-lang vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms
cp51932 hebrew greek romanian slovak czech european ethiopic indian
cyrillic chinese charscript case-table epa-hook jka-cmpr-hook help
simple abbrev minibuffer cl-preloaded nadvice loaddefs button faces
cus-face macroexp files text-properties overlay sha1 md5 base64 format
env code-pages mule custom widget hashtable-print-readable backquote
w32notify w32 multi-tty make-network-process emacs)

Memory information:
((conses 16 1939675 254301)
 (symbols 56 65485 5)
 (miscs 48 6170 9939)
 (strings 32 235134 58653)
 (string-bytes 1 6115616)
 (vectors 16 77899)
 (vector-slots 8 2183332 138416)
 (floats 8 548 657)
 (intervals 56 272788 648)
 (buffers 976 205))


reply via email to

[Prev in Thread] Current Thread [Next in Thread]