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

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

Re: Symbols as words?


From: Raffaele Ricciardi
Subject: Re: Symbols as words?
Date: Mon, 27 Aug 2012 14:57:11 +0100
User-agent: Mozilla/5.0 (X11; Linux i686; rv:14.0) Gecko/20120713 Thunderbird/14.0

On 26/08/12 19:12, Pascal J. Bourguignon wrote:
> If you use forward-sexp C-M-f it skips over symbols instead of words M-f.

This helps, thanks. Still, it feels weird that Emacs is oblivious to symbols even in Emacs Lisp code, not to mention that C-M- chords aren't super comfortable. So, since there is no option to customize this behaviour, I've written a snippet of code to do so for any programming mode. I would have preferred my code to
scan the syntax table and convert symbol constituents to word constituents,
but I have not been able to figure out quickly the format of syntax tables,
therefore I've resorted to manually listing non-word graphic characters.

(defun rr-symbol-constituent-p (^char)
"Return non non nil if ^CHAR is a symbol constituent in the current buffer's
syntax table."
  (= (char-syntax ^char) ?_))

(defvar rr-graphic-non-word-char-list
  (string-to-list "!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~")
  "List of characters besides letters and numbers that could be symbol
constituents according to syntax tables.")

(defun rr-symbols-to-words ()
  "Make symbols act as words in the current buffer's syntax table."
  (mapcar (lambda (^char)
            (when (rr-symbol-constituent-p ^char)
              (modify-syntax-entry ^char "w")))
          rr-graphic-non-word-char-list))

Cheers.


reply via email to

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