From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Mark Oteiza Newsgroups: gmane.emacs.bugs Subject: bug#21465: [PATCH] CC-modes hierarchy Date: Sat, 12 Sep 2015 12:51:47 -0400 Message-ID: <87pp1neg2k.fsf@udel.edu> References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: ger.gmane.org 1442076744 701 80.91.229.3 (12 Sep 2015 16:52:24 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 12 Sep 2015 16:52:24 +0000 (UTC) To: 21465@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Sep 12 18:52:12 2015 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1Zao27-0008PT-73 for geb-bug-gnu-emacs@m.gmane.org; Sat, 12 Sep 2015 18:52:11 +0200 Original-Received: from localhost ([::1]:33169 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zao26-0005gu-H8 for geb-bug-gnu-emacs@m.gmane.org; Sat, 12 Sep 2015 12:52:10 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:45303) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zao22-0005fu-Rg for bug-gnu-emacs@gnu.org; Sat, 12 Sep 2015 12:52:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zao21-0001ce-QN for bug-gnu-emacs@gnu.org; Sat, 12 Sep 2015 12:52:06 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:38062) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zao1x-0001ZJ-W2; Sat, 12 Sep 2015 12:52:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1Zao1x-0007eB-Q5; Sat, 12 Sep 2015 12:52:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Mark Oteiza Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org, bug-cc-mode@gnu.org Resent-Date: Sat, 12 Sep 2015 16:52:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 21465 X-GNU-PR-Package: emacs,cc-mode X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.144207671929387 (code B ref -1); Sat, 12 Sep 2015 16:52:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 12 Sep 2015 16:51:59 +0000 Original-Received: from localhost ([127.0.0.1]:58505 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Zao1v-0007du-9J for submit@debbugs.gnu.org; Sat, 12 Sep 2015 12:51:59 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:35171) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Zao1s-0007dm-Cl for submit@debbugs.gnu.org; Sat, 12 Sep 2015 12:51:57 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zao1r-0001WV-3M for submit@debbugs.gnu.org; Sat, 12 Sep 2015 12:51:55 -0400 Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:46510) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zao1r-0001WI-0i for submit@debbugs.gnu.org; Sat, 12 Sep 2015 12:51:55 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:45150) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zao1q-0005fK-0W for bug-gnu-emacs@gnu.org; Sat, 12 Sep 2015 12:51:54 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zao1m-0001Ub-QS for bug-gnu-emacs@gnu.org; Sat, 12 Sep 2015 12:51:53 -0400 Original-Received: from mail-qk0-f171.google.com ([209.85.220.171]:35605) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zao1m-0001UX-LR for bug-gnu-emacs@gnu.org; Sat, 12 Sep 2015 12:51:50 -0400 Original-Received: by qkap81 with SMTP id p81so43783706qka.2 for ; Sat, 12 Sep 2015 09:51:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:references:date:in-reply-to :message-id:user-agent:mime-version:content-type; bh=n5xOXPALS39Um38N1vr4ukvMlyFczNygajNaM/o/Wbk=; b=dPU9UmAkg6OQU+YVnGXwxRdHjGfvx23nB4OwDRl2z8MibsSJ5QGJtv5QTi21VYlynA wLOAdVDtyJhEo/TpmZNZZY0Qlq4STjqanrzseiVYAnDNvopfoHXQ7IhvwqF+KmiaC2dn ZfoynhusJ3UgpkmxDrWQ8yxtHTU61CdO5U0yhjUjGkXh38POaLGFkQ2jNja7iArGm8sI HqtgkrdCAQ2esBqhPXtAooNcjCB6RmkE6tqOAYzIHkw2RBgADAk5dPs2B86aMJPlMdUI 2no+eNtiw04VIGQPD1m7q82QBzVn7dUvzzgzxTjrztG36aqIcXPdzuz4ZOJ/+yC+oq+L LTdw== X-Gm-Message-State: ALoCoQlBBEfbfViv2RWTqi17uD+RwN+zobHjvTMVe/KXx5GkYXd4kSlt7YCWkB7RjJlQn30wtWax X-Received: by 10.55.197.213 with SMTP id k82mr7346448qkl.49.1442076710060; Sat, 12 Sep 2015 09:51:50 -0700 (PDT) Original-Received: from holos.localdomain (c-73-172-248-173.hsd1.md.comcast.net. [73.172.248.173]) by smtp.gmail.com with ESMTPSA id z19sm2333699qge.38.2015.09.12.09.51.48 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 12 Sep 2015 09:51:49 -0700 (PDT) Original-Received: by holos.localdomain (Postfix, from userid 1000) id 25F8068971; Sat, 12 Sep 2015 12:51:47 -0400 (EDT) In-Reply-To: (Stefan Monnier's message of "Fri, 11 Sep 2015 22:32:00 -0400") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:106456 Archived-At: --=-=-= Content-Type: text/plain Stefan Monnier writes: > Package: Emacs > Version: 25.0.50 > - Move code common to all CC-mode major modes to a c-mode-common-mode function. > - Add new c-derivative-mode as a parent of C, C++, and ObjC, for > settings which apply to C-derived languages but not for others. > This has become necessary given that CC-mode is used nowadays as an > engine for modes which have little to do with C. > ... > - Remove c-make-inherited-keymap, since it's not used any more. It is not clear to me how to adapt a 3rd party derived mode to this. Granted, it was never clear to me how to make a mode derived from CC mode, but that's another thread. For mode derivation, either I have (define-derived-mode foo++-mode c++-mode "Foo++" ...) In which case there will be a parent c++-mode-map and a C++ menu present when there shouldn't be, or: (define-derived-mode foo++-mode c-derivative-mode "Foo++" ...) and fontification is broken. I've attached an example: --=-=-= Content-Type: application/emacs-lisp Content-Disposition: inline; filename=freefem++-mode.el Content-Transfer-Encoding: quoted-printable Content-Description: freefem++ mode ;;; freefem++-mode.el --- Major mode for the FreeFem++ language ;; Copyright =C2=A9 2014-2015 Mark Oteiza ;; Copyright =C2=A9 2008-2011 J. Rafael Rodr=C3=ADguez Galv=C3=A1n ;; Author: Mark Oteiza ;; J. Rafael Rodr=C3=ADguez Galv=C3=A1n ;; Created: 25 Jan 2014 ;; Version: 0.3 ;; Keywords: languages ;; This file is free software: you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published ;; by the Free Software Foundation, either version 3 of the License, ;; or (at your option) any later version. ;; This file is distributed in the hope that it will be useful, but ;; WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; General Public License for more details. ;; You should have received a copy of the GNU General Public License ;; along with this file. If not, see . ;;; Commentary: ;; Inspired by `freefem++-mode.el' by J. Rafael Rodr=C3=ADguez Galv=C3=A1n. ;; ;; FreeFem++ is a partial differential ;; equation solver. It has its own language. FreeFem++ scripts can ;; solve multiphysics nonlinear systems in 2D and 3D. ;;; Code: (defgroup freefem++ nil "Support for the FreeFem++ language." :group 'languages :link '(url-link "http://www.freefem.org/ff++/") :prefix "freefem++-") (require 'cc-mode) (require 'compile) (eval-when-compile (require 'cl) ;temporary (require 'cc-langs) (require 'cc-fonts)) (eval-and-compile (c-add-language 'freefem++-mode 'c++-mode)) ;;; Lexer-level syntax (identifiers, tokens etc). (c-lang-defconst c-symbol-chars ;; No underscore or other symbols permitted in identifiers freefem++ c-alnum) (c-lang-defconst c-cpp-include-directives freefem++ '("include" "load")) (c-lang-defconst c-opt-cpp-macro-define freefem++ "macro") ;; Additional constants for parser-level constructs. (c-lang-defconst c-type-decl-prefix-key ;; No pointers, casting, or &=3D operator, only references freefem++ (concat "\\(&\\)\\([^=3D]\\|$\\)")) (c-lang-defconst c-opt-type-suffix-key ;; Arrays freefem++ "\\(\\[[^]]*\\]\\|\\[\<^\>]*\\]\\)") ;; Keyword lists. (c-lang-defconst c-primitive-type-kwds freefem++ '("bool" "border" "Cmatrix" "complex" "func" "ifstream" "int" "macro" "matrix" "mesh" "mesh3" "ofstream" "problem" "real" "R3" "solve" "string" "varf")) (c-lang-defconst c-primitive-type-prefix-kwds ;; Both here and in `c-primitive-type-kwds' freefem++ '("func")) (c-lang-defconst c-paren-nontype-kwds freefem++ '("int1d" "int2d" "int3d" "intalledges" "on" "jump" "mean" "dx" "dxx" "dxy" "dy" "dyx" "dyy" "dz" "interpolate" "set" "plot")) (c-lang-defconst c-constant-kwds freefem++ '("true" "false" "pi" ;; Reserved "P" "N" ;; Finite elements "P0" "P1" "P2" "P3" "P4" "P0VF" "P1nc" "P1dc" "P2dc" "P1b" "P2b" "P2h" "RT0" "RT1" "BDM1" "RT0Ortho" "RT1Ortho" "BDM1Ortho" "RTmodif" "P0edge" "P1edge" "P2edge" "P3edge" "P4edge" "P5edge" "P03d" "P13d" "P1b3d" "P23d" "RT03d" "Edge03d" ;; Solvers "LU" "Cholesky" "Crout" "CG" "GMRES" "UMFPACK" "sparsesolver" ;; Quadrature finite elements "qf1pE" "qf2pE" "qf3pE" "qf4pE" "qf5pE" "qf1pElump")) ;; Font Lock linking (defconst freefem++-font-lock-keywords-1 (c-lang-const c-matchers-1 freefem= ++) "Minimal highlighting for FreeFem++ mode.") (defconst freefem++-font-lock-keywords-2 (c-lang-const c-matchers-2 freefem= ++) "Fast normal highlighting for FreeFem++ mode.") (defconst freefem++-font-lock-keywords-3 (c-lang-const c-matchers-3 freefem= ++) "Accurate normal highlighting for FreeFem++ mode.") (defvar freefem++-font-lock-keywords freefem++-font-lock-keywords-3 "Default expressions to highlight in FreeFem++ mode.") ;; Program invocation (defcustom freefem++-program "FreeFem++" "Command used to execute the FreeFem++ compiler. See also `freefem++-program-options'." :type 'string :group 'freefem++) (defcustom freefem++-program-options (list "-ne") "Options applied to `freefem++-program'. Options: -v , level of freefem output (0--1000000) -fglut , the file name of save all plots (replot with ffglut comma= nd) -glut , change compatible with ffglut -gff , change compatible with ffglut (with space quoti= ng) -nowait, nowait at the end on window -wait, wait at the end on window -nw, no ffglut, ffmedit (=3D> no graphics windows) -ne, no edp script output -cd, Change dir to script dir" :type '(repeat string) :group 'freefem++) (defcustom freefem++-run-error-regexp-alist '(("^ Error line number \\([0-9]+\\), in file \\([[:alpha:]][-[:alnum:].]= +\\)," 2 1)) "Alist that specifies how to match errors in FreeFem++ output." :type 'alist :link '(variable-link compilation-error-regexp-alist) :group 'freefem++) (defvar-local freefem++-process nil "Process currently executing `freefem++-program'") (defun freefem++-kill-process () "Send kill signal to FreeFem++ process." (interactive) (interrupt-process freefem++-process)) (define-compilation-mode freefem++-run-mode "Compilation" "Major mode for FreeFem++ compilation log buffers.") (defun freefem++-run-buffer () "Send current buffer to FreeFem++." (interactive) (save-some-buffers) (let ((file (file-name-nondirectory buffer-file-name)) (command (mapconcat #'identity (cons freefem++-program freefem++-program-options) " "))) (setq freefem++-process (compilation-start (concat command " " file) 'freefem++-run-mode)))) ;; Easy menu (c-lang-defconst c-mode-menu ;; The definition for the mode menu. The menu title is prepended to ;; this before it's fed to `easy-menu-define'. t `(["Process this buffer" freefem++-run-buffer t] ["Kill FreeFem++ process" freefem++-kill-process t] "---" ["Comment Out Region" comment-dwim (c-fn-region-is-active-p)] ["Uncomment Region" comment-dwim (c-fn-region-is-active-p)] ["Indent Expression" c-indent-exp (memq (char-after) '(?\( ?\[ ?\{))] ["Indent Line or Region" c-indent-line-or-region t] ["Fill Comment Paragraph" c-fill-paragraph t] "----" ["Backward Statement" c-beginning-of-statement t] ["Forward Statement" c-end-of-statement t] "----" ("Toggle..." ["Syntactic indentation" c-toggle-syntactic-indentation :style toggle :selected c-syntactic-indentation] ["Electric mode" c-toggle-electric-state :style toggle :selected c-electric-flag] ["Auto newline" c-toggle-auto-newline :style toggle :selected c-auto-newline] ["Hungry delete" c-toggle-hungry-state :style toggle :selected c-hungry-delete-key] ["Subword mode" c-subword-mode :style toggle :selected (and (boundp 'c-subword-mode) c-subword-mode)]))) ;; Support for FreeFem++ (defvar freefem++-mode-syntax-table (let ((table (make-syntax-table))) (modify-syntax-entry ?' "_" table) table) "Syntax table used in `freefem++-mode' buffers.") (defvar freefem++-mode-abbrev-table nil "Abbreviation table used in `freefem++-mode' buffers.") (c-define-abbrev-table 'freefem++-mode-abbrev-table '(("else" "else" c-electric-continued-statement 0) ("while" "while" c-electric-continued-statement 0) ("catch" "catch" c-electric-continued-statement 0))) (defvar freefem++-mode-map (let ((map (if (fboundp 'c-make-inherited-keymap) (c-make-inherited-keymap) (make-sparse-keymap)))) (define-key map (kbd "C-c C-c") 'freefem++-run-buffer) (define-key map (kbd "C-c C-k") 'freefem++-kill-process) map) "Keymap used in `freefem++-mode' buffers.") (easy-menu-define freefem++-menu freefem++-mode-map "FreeFem++ Mode Command= s" (cons "FreeFem++" (c-lang-const c-mode-menu freefem++))) ;;;###autoload (add-to-list 'auto-mode-alist '("\\.[ei]dp\\'" . freefem++-m= ode)) (defalias 'freefem++-parent-mode (if (fboundp 'c-derivative-mode) 'c-derivative-mode 'c++-mode)) ;;;###autoload (define-derived-mode freefem++-mode freefem++-parent-mode "FreeFem++" "Major mode for editing code written in the FreeFem++ programming languag= e. See http://www.freefem.org/ff++/ for more information about the FreeFem++ language. In addition to any hooks its parent mode might have run, this mode runs the hook `freefem++-mode-hook' as the final step during initialization. Key bindings: \\{freefem++-mode-map}" :group 'freefem++ (c-initialize-cc-mode t) (c-init-language-vars freefem++-mode) (c-common-init 'freefem++-mode) (easy-menu-add freefem++-menu) (cc-imenu-init cc-imenu-c++-generic-expression) (c-update-modeline)) (provide 'freefem++-mode) ;;; freefem++-mode.el ends here --=-=-=--