From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Ted Zlatanov Newsgroups: gmane.emacs.devel 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 Organization: =?utf-8?B?0KLQtdC+0LTQvtGAINCX0LvQsNGC0LDQvdC+0LI=?= @ Cienfuegos Message-ID: <878v5fxzjg.fsf@lifelogs.com> References: <87wqt0xqiy.fsf@lifelogs.com> <87sj3ny4ca.fsf@lifelogs.com> <87ehf7zid3.fsf@fleche.redhat.com> <87obeby2ph.fsf@lifelogs.com> Reply-To: emacs-devel@gnu.org NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: ger.gmane.org 1363963628 27852 80.91.229.3 (22 Mar 2013 14:47:08 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 22 Mar 2013 14:47:08 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Mar 22 15:47:34 2013 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1UJ3Fi-0007QN-F6 for ged-emacs-devel@m.gmane.org; Fri, 22 Mar 2013 15:47:30 +0100 Original-Received: from localhost ([::1]:50492 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UJ3FL-00062Z-4P for ged-emacs-devel@m.gmane.org; Fri, 22 Mar 2013 10:47:07 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:42883) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UJ3FG-000624-2M for emacs-devel@gnu.org; Fri, 22 Mar 2013 10:47:04 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UJ3FE-0007cs-3F for emacs-devel@gnu.org; Fri, 22 Mar 2013 10:47:02 -0400 Original-Received: from plane.gmane.org ([80.91.229.3]:49538) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UJ3FD-0007bt-Mr for emacs-devel@gnu.org; Fri, 22 Mar 2013 10:47:00 -0400 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1UJ3FX-0007Hm-5L for emacs-devel@gnu.org; Fri, 22 Mar 2013 15:47:19 +0100 Original-Received: from pool-72-70-75-213.bstnma.east.verizon.net ([72.70.75.213]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 22 Mar 2013 15:47:19 +0100 Original-Received: from tzz by pool-72-70-75-213.bstnma.east.verizon.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 22 Mar 2013 15:47:19 +0100 X-Injected-Via-Gmane: http://gmane.org/ Mail-Followup-To: emacs-devel@gnu.org Original-Lines: 243 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: pool-72-70-75-213.bstnma.east.verizon.net X-Face: bd.DQ~'29fIs`T_%O%C\g%6jW)yi[zuz6; d4V0`@y-~$#3P_Ng{@m+e4o<4P'#(_GJQ%TT= D}[Ep*b!\e,fBZ'j_+#"Ps?s2!4H2-Y"sx" Mail-Copies-To: never User-Agent: Gnus/5.130006 (Ma Gnus v0.6) Emacs/24.3.50 (gnu/linux) Cancel-Lock: sha1:1Ifh1t2ZpkNtQKvtINhYwzF1IGI= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 80.91.229.3 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:158065 Archived-At: --=-=-= Content-Type: text/plain On Fri, 22 Mar 2013 10:18:37 -0400 Stefan Monnier 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 --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=cfengine-symbol-syntax.patch === 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" "\\[ \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" "\\_[ \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)))) --=-=-=--