From: Ted Zlatanov <tzz@lifelogs.com>
To: emacs-devel@gnu.org
Subject: Re: [Emacs-diffs] /srv/bzr/emacs/trunk r112104: * progmodes/cfengine.el (cfengine-common-syntax): Add "_" to word syntax.
Date: Fri, 22 Mar 2013 10:46:43 -0400 [thread overview]
Message-ID: <878v5fxzjg.fsf@lifelogs.com> (raw)
In-Reply-To: jwvppyrttd0.fsf-monnier+emacs@gnu.org
[-- Attachment #1: Type: text/plain, Size: 1815 bytes --]
On Fri, 22 Mar 2013 10:18:37 -0400 Stefan Monnier <monnier@iro.umontreal.ca> wrote:
>> OK, but I can't think of any cases in CFEngine specifically where I
>> don't want to skip over _ with M-f. It's always part of a word.
>> The language itself is designed that way and has a pretty rigid syntax.
SM> CFengine has no notion of words, it has a notion of identifiers, which
SM> in Emacs are called symbols and can be skipped with C-M-f or
SM> forward-symbol.
>> Or are you saying users don't expect _ to be part of a
>> word and it's unconventional to make it so?
SM> Exactly. Many users actually like _ to be part of a word, but these are
SM> user-preferences (and we should indeed define a words-are-symbols-mode
SM> for those users since what they really want is for M-f, M-t, M-DEL to
SM> move by symbols rather than by words).
Yes! In particular, context expressions in CFEngine are things like
"a_b_c.d_e" and it's a pain to skip over them with the usual `M-f' or
CUA keybindings. It would be nice to be able to set this as a
preference for all modes derived from `prog-mode', IIUC what you mean.
SM> Basically, the definition of a word is something that major modes should
SM> not touch, because it is a notion from human language, and not from the
SM> programming language in use in a particular buffer.
SM> The major mode should define the syntax of symbols (aka
SM> "identifiers") instead.
OK, I think I understand. You're saying "words" are not part of the
syntax for a programming language, generally, and are more of a
text-mode concept. Symbols usually are what I want if I'm parsing a
programming language.
I modified cfengine.el to use \_< and \_> for all the regular
expressions; can you take a look at the attached patch and see if it's
closer to the expected behavior?
Thanks
Ted
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: cfengine-symbol-syntax.patch --]
[-- Type: text/x-diff, Size: 6828 bytes --]
=== modified file 'lisp/progmodes/cfengine.el'
*** lisp/progmodes/cfengine.el 2013-03-21 16:11:13 +0000
--- lisp/progmodes/cfengine.el 2013-03-22 14:39:32 +0000
***************
*** 30,40 ****
;; The CFEngine 3.x support doesn't have Imenu support but patches are
;; welcome.
;; You can set it up so either `cfengine2-mode' (2.x and earlier) or
;; `cfengine3-mode' (3.x) will be picked, depending on the buffer
;; contents:
! ;; (add-to-list 'auto-mode-alist '("\\.cf\\'" . cfengine-mode))
;; OR you can choose to always use a specific version, if you prefer
;; it:
--- 30,42 ----
;; The CFEngine 3.x support doesn't have Imenu support but patches are
;; welcome.
+ ;; By default, CFEngine 3.x syntax is used.
+
;; You can set it up so either `cfengine2-mode' (2.x and earlier) or
;; `cfengine3-mode' (3.x) will be picked, depending on the buffer
;; contents:
! ;; (add-to-list 'auto-mode-alist '("\\.cf\\'" . cfengine-auto-mode))
;; OR you can choose to always use a specific version, if you prefer
;; it:
***************
*** 181,187 ****
("$(\\([[:alnum:]_]+\\))" 1 font-lock-variable-name-face)
("${\\([[:alnum:]_]+\\)}" 1 font-lock-variable-name-face)
;; Variable definitions.
! ("\\<\\([[:alnum:]_]+\\)[ \t]*=[ \t]*(" 1 font-lock-variable-name-face)
;; File, acl &c in group: { token ... }
("{[ \t]*\\([^ \t\n]+\\)" 1 font-lock-constant-face)))
--- 183,189 ----
("$(\\([[:alnum:]_]+\\))" 1 font-lock-variable-name-face)
("${\\([[:alnum:]_]+\\)}" 1 font-lock-variable-name-face)
;; Variable definitions.
! ("\\_<\\([[:alnum:]_]+\\)[ \t]*=[ \t]*(" 1 font-lock-variable-name-face)
;; File, acl &c in group: { token ... }
("{[ \t]*\\([^ \t\n]+\\)" 1 font-lock-constant-face)))
***************
*** 189,197 ****
`(
;; Defuns. This happens early so they don't get caught by looser
;; patterns.
! (,(concat "\\<" cfengine3-defuns-regex "\\>"
! "[ \t]+\\<\\([[:alnum:]_.:]+\\)\\>"
! "[ \t]+\\<\\([[:alnum:]_.:]+\\)"
;; Optional parentheses with variable names inside.
"\\(?:(\\([^)]*\\))\\)?")
(1 font-lock-builtin-face)
--- 191,199 ----
`(
;; Defuns. This happens early so they don't get caught by looser
;; patterns.
! (,(concat "\\_<" cfengine3-defuns-regex "\\_>"
! "[ \t]+\\_<\\([[:alnum:]_.:]+\\)\\_>"
! "[ \t]+\\_<\\([[:alnum:]_.:]+\\)"
;; Optional parentheses with variable names inside.
"\\(?:(\\([^)]*\\))\\)?")
(1 font-lock-builtin-face)
***************
*** 212,221 ****
("[@$]{\\([[:alnum:]_.:]+\\)}" 1 font-lock-variable-name-face)
;; Variable definitions.
! ("\\<\\([[:alnum:]_]+\\)[ \t]*=[ \t]*(" 1 font-lock-variable-name-face)
;; Variable types.
! (,(concat "\\<" (eval-when-compile (regexp-opt cfengine3-vartypes t)) "\\>")
1 font-lock-type-face)))
(defvar cfengine2-imenu-expression
--- 214,223 ----
("[@$]{\\([[:alnum:]_.:]+\\)}" 1 font-lock-variable-name-face)
;; Variable definitions.
! ("\\_<\\([[:alnum:]_]+\\)[ \t]*=[ \t]*(" 1 font-lock-variable-name-face)
;; Variable types.
! (,(concat "\\_<" (eval-when-compile (regexp-opt cfengine3-vartypes t)) "\\_>")
1 font-lock-type-face)))
(defvar cfengine2-imenu-expression
***************
*** 223,231 ****
(regexp-opt cfengine2-actions t))
":[^:]")
1)
! ("Variables/classes" "\\<\\([[:alnum:]_]+\\)[ \t]*=[ \t]*(" 1)
! ("Variables/classes" "\\<define=\\([[:alnum:]_]+\\)" 1)
! ("Variables/classes" "\\<DefineClass\\>[ \t]+\\([[:alnum:]_]+\\)" 1))
"`imenu-generic-expression' for CFEngine mode.")
(defun cfengine2-outline-level ()
--- 225,233 ----
(regexp-opt cfengine2-actions t))
":[^:]")
1)
! ("Variables/classes" "\\_<\\([[:alnum:]_]+\\)[ \t]*=[ \t]*(" 1)
! ("Variables/classes" "\\_<define=\\([[:alnum:]_]+\\)" 1)
! ("Variables/classes" "\\_<DefineClass\\>[ \t]+\\([[:alnum:]_]+\\)" 1))
"`imenu-generic-expression' for CFEngine mode.")
(defun cfengine2-outline-level ()
***************
*** 338,344 ****
Treats body/bundle blocks as defuns."
(unless (<= (current-column) (current-indentation))
(end-of-line))
! (if (re-search-backward (concat "^[ \t]*" cfengine3-defuns-regex "\\>") nil t)
(beginning-of-line)
(goto-char (point-min)))
t)
--- 340,346 ----
Treats body/bundle blocks as defuns."
(unless (<= (current-column) (current-indentation))
(end-of-line))
! (if (re-search-backward (concat "^[ \t]*" cfengine3-defuns-regex "\\_>") nil t)
(beginning-of-line)
(goto-char (point-min)))
t)
***************
*** 347,353 ****
"`end-of-defun' function for Cfengine 3 mode.
Treats body/bundle blocks as defuns."
(end-of-line)
! (if (re-search-forward (concat "^[ \t]*" cfengine3-defuns-regex "\\>") nil t)
(beginning-of-line)
(goto-char (point-max)))
t)
--- 349,355 ----
"`end-of-defun' function for Cfengine 3 mode.
Treats body/bundle blocks as defuns."
(end-of-line)
! (if (re-search-forward (concat "^[ \t]*" cfengine3-defuns-regex "\\_>") nil t)
(beginning-of-line)
(goto-char (point-max)))
t)
***************
*** 366,372 ****
(cond
;; Body/bundle blocks start at 0.
! ((looking-at (concat cfengine3-defuns-regex "\\>"))
(indent-line-to 0))
;; Categories are indented one step.
((looking-at (concat cfengine3-category-regex "[ \t]*\\(#.*\\)*$"))
--- 368,374 ----
(cond
;; Body/bundle blocks start at 0.
! ((looking-at (concat cfengine3-defuns-regex "\\_>"))
(indent-line-to 0))
;; Categories are indented one step.
((looking-at (concat cfengine3-category-regex "[ \t]*\\(#.*\\)*$"))
***************
*** 516,522 ****
(defun cfengine-common-syntax (table)
;; The syntax defaults seem OK to give reasonable word movement.
- (modify-syntax-entry ?w "_" table)
(modify-syntax-entry ?# "<" table)
(modify-syntax-entry ?\n ">#" table)
(modify-syntax-entry ?\" "\"" table) ; "string"
--- 518,523 ----
***************
*** 584,590 ****
(save-restriction
(goto-char (point-min))
(while (not (or (eobp) v3))
! (setq v3 (looking-at (concat cfengine3-defuns-regex "\\>")))
(forward-line)))
(if v3 (cfengine3-mode) (cfengine2-mode))))
--- 585,591 ----
(save-restriction
(goto-char (point-min))
(while (not (or (eobp) v3))
! (setq v3 (looking-at (concat cfengine3-defuns-regex "\\_>")))
(forward-line)))
(if v3 (cfengine3-mode) (cfengine2-mode))))
next prev parent reply other threads:[~2013-03-22 14:46 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <E1UIiBH-0005sm-Vy@vcs.savannah.gnu.org>
2013-03-21 23:44 ` [Emacs-diffs] /srv/bzr/emacs/trunk r112104: * progmodes/cfengine.el (cfengine-common-syntax): Add "_" to word syntax Stefan Monnier
2013-03-21 23:49 ` Ted Zlatanov
2013-03-22 1:32 ` Stefan Monnier
2013-03-22 13:03 ` Ted Zlatanov
2013-03-22 13:14 ` Tom Tromey
2013-03-22 13:38 ` Ted Zlatanov
2013-03-22 14:18 ` Stefan Monnier
2013-03-22 14:46 ` Ted Zlatanov [this message]
2013-03-22 17:30 ` Stefan Monnier
2013-03-22 19:13 ` Ted Zlatanov
2013-03-23 16:01 ` Stefan Monnier
2013-03-26 9:17 ` Ted Zlatanov
2013-03-26 17:06 ` Stefan Monnier
2013-03-26 19:04 ` superword-mode (was: [Emacs-diffs] /srv/bzr/emacs/trunk r112104: * progmodes/cfengine.el (cfengine-common-syntax): Add "_" to word syntax.) Ted Zlatanov
2013-03-27 1:23 ` superword-mode Stefan Monnier
2013-03-27 3:18 ` superword-mode Masatake YAMATO
2013-03-27 9:31 ` superword-mode Andreas Schwab
2013-03-27 13:06 ` superword-mode Ted Zlatanov
2013-03-27 13:14 ` superword-mode Stefan Monnier
2013-03-27 13:04 ` superword-mode Ted Zlatanov
2013-03-27 13:50 ` superword-mode Stefan Monnier
2013-03-27 14:06 ` superword-mode Ted Zlatanov
2013-03-27 15:03 ` superword-mode Davis Herring
2013-03-27 15:19 ` superword-mode Ted Zlatanov
2013-03-27 15:33 ` superword-mode Ted Zlatanov
2013-03-27 16:33 ` superword-mode Stefan Monnier
2013-03-27 19:31 ` superword-mode Ted Zlatanov
2013-03-27 22:23 ` superword-mode Stefan Monnier
2013-03-28 23:00 ` superword-mode Ted Zlatanov
2013-03-29 13:26 ` superword-mode Ted Zlatanov
2013-03-29 16:23 ` superword-mode Andreas Röhler
2013-03-29 16:43 ` superword-mode Ted Zlatanov
2013-03-29 17:49 ` superword-mode Andreas Röhler
2013-03-29 18:10 ` superword-mode Ted Zlatanov
2013-03-29 18:50 ` superword-mode Andreas Röhler
2013-03-29 19:04 ` superword-mode Ted Zlatanov
2013-03-29 20:16 ` superword-mode Davis Herring
2013-03-29 21:18 ` superword-mode Stefan Monnier
2013-03-30 1:34 ` superword-mode Ted Zlatanov
2013-03-30 1:36 ` superword-mode Ted Zlatanov
2013-03-30 6:28 ` superword-mode Andreas Röhler
2013-03-22 14:13 ` [Emacs-diffs] /srv/bzr/emacs/trunk r112104: * progmodes/cfengine.el (cfengine-common-syntax): Add "_" to word syntax Stefan Monnier
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=878v5fxzjg.fsf@lifelogs.com \
--to=tzz@lifelogs.com \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.