From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.cc-mode.general,gmane.emacs.devel Subject: Re: Reify the cc-mode-common into an actual parent mode Date: Sat, 28 May 2016 11:30:03 +0000 Message-ID: <20160528113003.GA2950@acm.fritz.box> References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1464435068 19527 80.91.229.3 (28 May 2016 11:31:08 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 28 May 2016 11:31:08 +0000 (UTC) Cc: bug-cc-mode@gnu.org, emacs-devel@gnu.org To: Stefan Monnier Original-X-From: cc-mode-help-bounces@lists.sourceforge.net Sat May 28 13:30:58 2016 Return-path: Envelope-to: sf-cc-mode-help@m.gmane.org Original-Received: from lists.sourceforge.net ([216.34.181.88]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1b6cSH-0003KJ-KP for sf-cc-mode-help@m.gmane.org; Sat, 28 May 2016 13:30:58 +0200 Original-Received: from localhost ([127.0.0.1] helo=sfs-ml-2.v29.ch3.sourceforge.com) by sfs-ml-2.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1b6cS1-0008Go-1z; Sat, 28 May 2016 11:30:41 +0000 Original-Received: from sog-mx-2.v43.ch3.sourceforge.com ([172.29.43.192] helo=mx.sourceforge.net) by sfs-ml-2.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1b6cRz-0008Gb-Eh for cc-mode-help@lists.sourceforge.net; Sat, 28 May 2016 11:30:39 +0000 Received-SPF: neutral (sog-mx-2.v43.ch3.sourceforge.com: 208.118.235.92 is neither permitted nor denied by domain of muc.de) client-ip=208.118.235.92; envelope-from=acm@muc.de; helo=eggs.gnu.org; Original-Received: from eggs.gnu.org ([208.118.235.92]) by sog-mx-2.v43.ch3.sourceforge.com with esmtps (TLSv1:AES256-SHA:256) (Exim 4.76) id 1b6cRv-0002Jp-ML for cc-mode-help@lists.sourceforge.net; Sat, 28 May 2016 11:30:39 +0000 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b6cRo-0005ur-17 for cc-mode-help@lists.sourceforge.net; Sat, 28 May 2016 07:30:30 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50 autolearn=disabled version=3.3.2 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:37993) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b6cRn-0005um-Tp for cc-mode-help@lists.sourceforge.net; Sat, 28 May 2016 07:30:27 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:42715) by fencepost.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1b6cRm-0000Xj-7V for bug-cc-mode@gnu.org; Sat, 28 May 2016 07:30:26 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b6cRh-0005t6-FK for bug-cc-mode@gnu.org; Sat, 28 May 2016 07:30:24 -0400 Original-Received: from mail.muc.de ([193.149.48.3]:59944) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b6cRg-0005rg-PM for bug-cc-mode@gnu.org; Sat, 28 May 2016 07:30:21 -0400 Original-Received: (qmail 55375 invoked by uid 3782); 28 May 2016 11:30:01 -0000 Original-Received: from acm.muc.de (p548C6E65.dip0.t-ipconnect.de [84.140.110.101]) by colin.muc.de (tmda-ofmipd) with ESMTP; Sat, 28 May 2016 13:29:59 +0200 Original-Received: (qmail 4212 invoked by uid 1000); 28 May 2016 11:30:03 -0000 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) X-Delivery-Agent: TMDA/1.1.12 (Macallan) X-Primary-Address: acm@muc.de X-detected-operating-system: by eggs.gnu.org: FreeBSD 9.x X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-Spam-Score: 0.7 (/) X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. 0.7 SPF_NEUTRAL SPF: sender does not match SPF record (neutral) X-Headers-End: 1b6cRv-0002Jp-ML X-BeenThere: cc-mode-help@lists.sourceforge.net X-Mailman-Version: 2.1.9 Precedence: list List-Id: "Bug reports, feature requests, and general talk about CC Mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: cc-mode-help-bounces@lists.sourceforge.net Xref: news.gmane.org gmane.emacs.cc-mode.general:6856 gmane.emacs.devel:204109 Archived-At: Hello, Stefan. On Mon, May 23, 2016 at 08:41:56PM -0400, Stefan Monnier wrote: > IIRC last conversation, while you disagreed with introducing > a c-derivative-mode (for objc/c++/c), you said you were OK with the idea > of introducing a cc-mode-common. Did I? > Here's a corresponding patch. > Any objection? Just the same ones as we've already discussed. The patch will fragment the mode initialisations, making them more difficult to follow and understand. There's nothing coherent about what would be left in `c-mode', for example: just a few random forms which happen not to be shared by the other modes. There's nothing coherent about `c-mode-common'; it isn't sensible to set a buffer to this mode, and it would be erroneous to attempt to derive a mode (other than the seven within CC Mode) directly from it, since the language variables for the new mode wouldn't get initialised. It's doc string doesn't, as yet, make this latter point clear. The canonical way to create a mode derived from CC Mode is to derive from, say, `c-mode', call `c-add-language', then specify the values of the language variables which differ from those of `c-mode'. `c-update-modeline' should be called as the last thing in mode initialisation. The way the patch is structured, it gets called before `c-make-noise-macro-regexps' and `c-make-macro-with-semi-re' in those modes that have them. It so happens that, at the moment, those two functions don't affect `c-update-modeline', so things work, but this executing in the wrong order is storing up trouble for the future, should some form in `c-mode''s :after-hook position need executing before `c-update-modeline'. `c-make-inherited-keymap' is not obsolete, being required for XEmacs compatibility. (XEmacs is still alive, if perhaps on life support. SXEmacs is very much alive.) The alternative suggested in the patch's `make-obsolete' form most assuredly won't work in XEmacs, yet hackers aren't warned about this there. Likewise `c-run-mode-hooks' is not obsolete. The suggestion instead to derive directly from `c-common-mode' (note this should be `c-mode-common') is simply wrong (see above). But the main thing I don't like about the patch is that it's a lot of work (for both of us), yet doesn't solve a single bug, and doesn't implement any new feature. The new `c-mode-common', which isn't a coherent entity, is going to cause problems (and hence take up more time) when somebody tries to derive directly from it. Possibly there will be other problems with the patch. I'm really not keen on it. > Stefan > diff --git a/lisp/progmodes/cc-mode.el b/lisp/progmodes/cc-mode.el > index de903b8..bbb96f2 100644 > --- a/lisp/progmodes/cc-mode.el > +++ b/lisp/progmodes/cc-mode.el > @@ -238,6 +238,8 @@ control). See \"cc-mode.el\" for more info." > ;; incompatible > (t (error "CC Mode is incompatible with this version of Emacs"))) > map)) > +(make-obsolete 'c-make-inherited-keymap > + "Use make-sparse-keymap + (set-keymap-parent c-mode-base-map); or derive from c-mode-common" "26.1") This function is not obsolete. > (defun c-define-abbrev-table (name defs &optional doc) > ;; Compatibility wrapper for `define-abbrev' which passes a non-nil > @@ -861,6 +863,7 @@ Note that the style variables are always made local to the buffer." > (if (cc-bytecomp-fboundp 'run-mode-hooks) > `(run-mode-hooks ,@hooks) > `(progn ,@(mapcar (lambda (hook) `(run-hooks ,hook)) hooks)))) > +(make-obsolete 'c-run-mode-hooks "derive your mode from c-common-mode" "26.1") This function is also not obsolete: deriving from `c-mode-common' (note typo) is wrong (see above). > ;;; Change hooks, linking with Font Lock and electric-indent-mode. > @@ -1431,6 +1434,17 @@ This function is called from `c-common-init', once per mode initialization." > (c-update-modeline))) > +(defvar c-mode-common-map c-mode-base-map) > + > +(define-derived-mode c-mode-common prog-mode "CC-common" > + "Pseudo major mode, parent of all modes using the CC engine." NO!!! It is the parent of C Mode, C++ Mode, ....., AWK Mode, but is most definitely not the parent of modes derived from CC Mode (see above). > + ;; We want to update the mode-line but *after* the major mode's hooks > + ;; have been run. > + :after-hook (c-update-modeline) > + (c-initialize-cc-mode t) > + (setq abbrev-mode t) ;; Used for c-electric-continued-statement! > + ) > + > ;; Support for C > (defvar c-mode-syntax-table > @@ -1443,7 +1457,7 @@ This function is called from `c-common-init', once per mode initialization." > "Abbreviation table used in c-mode buffers.") > (defvar c-mode-map > - (let ((map (c-make-inherited-keymap))) > + (let ((map (make-sparse-keymap))) > ;; Add bindings which are only useful for C. > (define-key map "\C-c\C-e" 'c-macro-expand) > map) > @@ -1484,7 +1498,7 @@ This function is called from `c-common-init', once per mode initialization." > (unless (fboundp 'prog-mode) (defalias 'prog-mode 'fundamental-mode)) > ;;;###autoload > -(define-derived-mode c-mode prog-mode "C" > +(define-derived-mode c-mode c-mode-common "C" > "Major mode for editing C code. > To submit a problem report, enter `\\[c-submit-bug-report]' from a > @@ -1500,15 +1514,11 @@ initialization, then `c-mode-hook'. > Key bindings: > \\{c-mode-map}" > :after-hook (progn (c-make-noise-macro-regexps) > - (c-make-macro-with-semi-re) > - (c-update-modeline)) > - (c-initialize-cc-mode t) > - (setq abbrev-mode t) > + (c-make-macro-with-semi-re)) > (c-init-language-vars-for 'c-mode) > (c-common-init 'c-mode) > (easy-menu-add c-c-menu) > - (cc-imenu-init cc-imenu-c-generic-expression) > - (c-run-mode-hooks 'c-mode-common-hook)) > + (cc-imenu-init cc-imenu-c-generic-expression)) > ;; Support for C++ > @@ -1524,7 +1534,7 @@ Key bindings: > "Abbreviation table used in c++-mode buffers.") > (defvar c++-mode-map > - (let ((map (c-make-inherited-keymap))) > + (let ((map (make-sparse-keymap))) > ;; Add bindings which are only useful for C++. > (define-key map "\C-c\C-e" 'c-macro-expand) > (define-key map "\C-c:" 'c-scope-operator) > @@ -1537,7 +1547,7 @@ Key bindings: > (cons "C++" (c-lang-const c-mode-menu c++))) > ;;;###autoload > -(define-derived-mode c++-mode prog-mode "C++" > +(define-derived-mode c++-mode c-mode-common "C++" > "Major mode for editing C++ code. > To submit a problem report, enter `\\[c-submit-bug-report]' from a > c++-mode buffer. This automatically sets up a mail buffer with > @@ -1553,15 +1563,11 @@ initialization, then `c++-mode-hook'. > Key bindings: > \\{c++-mode-map}" > :after-hook (progn (c-make-noise-macro-regexps) > - (c-make-macro-with-semi-re) > - (c-update-modeline)) > - (c-initialize-cc-mode t) > - (setq abbrev-mode t) > + (c-make-macro-with-semi-re)) > (c-init-language-vars-for 'c++-mode) > (c-common-init 'c++-mode) > (easy-menu-add c-c++-menu) > - (cc-imenu-init cc-imenu-c++-generic-expression) > - (c-run-mode-hooks 'c-mode-common-hook)) > + (cc-imenu-init cc-imenu-c++-generic-expression)) > ;; Support for Objective-C > @@ -1576,7 +1582,7 @@ Key bindings: > "Abbreviation table used in objc-mode buffers.") > (defvar objc-mode-map > - (let ((map (c-make-inherited-keymap))) > + (let ((map (make-sparse-keymap))) > ;; Add bindings which are only useful for Objective-C. > (define-key map "\C-c\C-e" 'c-macro-expand) > map) > @@ -1588,7 +1594,7 @@ Key bindings: > ;;;###autoload (add-to-list 'auto-mode-alist '("\\.m\\'" . objc-mode)) > ;;;###autoload > -(define-derived-mode objc-mode prog-mode "ObjC" > +(define-derived-mode objc-mode c-mode-common "ObjC" > "Major mode for editing Objective C code. > To submit a problem report, enter `\\[c-submit-bug-report]' from an > objc-mode buffer. This automatically sets up a mail buffer with > @@ -1604,15 +1610,11 @@ initialization, then `objc-mode-hook'. > Key bindings: > \\{objc-mode-map}" > :after-hook (progn (c-make-noise-macro-regexps) > - (c-make-macro-with-semi-re) > - (c-update-modeline)) > - (c-initialize-cc-mode t) > - (setq abbrev-mode t) > + (c-make-macro-with-semi-re)) > (c-init-language-vars-for 'objc-mode) > (c-common-init 'objc-mode) > (easy-menu-add c-objc-menu) > - (cc-imenu-init nil 'cc-imenu-objc-function) > - (c-run-mode-hooks 'c-mode-common-hook)) > + (cc-imenu-init nil 'cc-imenu-objc-function)) > ;; Support for Java > @@ -1629,7 +1631,7 @@ Key bindings: > "Abbreviation table used in java-mode buffers.") > (defvar java-mode-map > - (let ((map (c-make-inherited-keymap))) > + (let ((map (make-sparse-keymap))) > ;; Add bindings which are only useful for Java. > map) > "Keymap used in java-mode buffers.") > @@ -1647,7 +1649,7 @@ Key bindings: > ;;;###autoload (add-to-list 'auto-mode-alist '("\\.java\\'" . java-mode)) > ;;;###autoload > -(define-derived-mode java-mode prog-mode "Java" > +(define-derived-mode java-mode c-mode-common "Java" > "Major mode for editing Java code. > To submit a problem report, enter `\\[c-submit-bug-report]' from a > java-mode buffer. This automatically sets up a mail buffer with > @@ -1662,14 +1664,10 @@ initialization, then `java-mode-hook'. > Key bindings: > \\{java-mode-map}" > - :after-hook (c-update-modeline) > - (c-initialize-cc-mode t) > - (setq abbrev-mode t) > (c-init-language-vars-for 'java-mode) > (c-common-init 'java-mode) > (easy-menu-add c-java-menu) > - (cc-imenu-init cc-imenu-java-generic-expression) > - (c-run-mode-hooks 'c-mode-common-hook)) > + (cc-imenu-init cc-imenu-java-generic-expression)) > ;; Support for CORBA's IDL language > @@ -1682,7 +1680,7 @@ Key bindings: > "Abbreviation table used in idl-mode buffers.") > (defvar idl-mode-map > - (let ((map (c-make-inherited-keymap))) > + (let ((map (make-sparse-keymap))) > ;; Add bindings which are only useful for IDL. > map) > "Keymap used in idl-mode buffers.") > @@ -1693,7 +1691,7 @@ Key bindings: > ;;;###autoload (add-to-list 'auto-mode-alist '("\\.idl\\'" . idl-mode)) > ;;;###autoload > -(define-derived-mode idl-mode prog-mode "IDL" > +(define-derived-mode idl-mode c-mode-common "IDL" > "Major mode for editing CORBA's IDL, PSDL and CIDL code. > To submit a problem report, enter `\\[c-submit-bug-report]' from an > idl-mode buffer. This automatically sets up a mail buffer with > @@ -1708,13 +1706,13 @@ initialization, then `idl-mode-hook'. > Key bindings: > \\{idl-mode-map}" > - :after-hook (c-update-modeline) > - (c-initialize-cc-mode t) > + ;; No c-electric-continued-statement here, so we don't need abbrev-mode. > + (kill-local-variable 'abbrev-mode) > (c-init-language-vars-for 'idl-mode) > (c-common-init 'idl-mode) > (easy-menu-add c-idl-menu) > ;;(cc-imenu-init cc-imenu-idl-generic-expression) ;TODO > - (c-run-mode-hooks 'c-mode-common-hook)) > + ) > ;; Support for Pike > @@ -1729,7 +1727,7 @@ Key bindings: > "Abbreviation table used in pike-mode buffers.") > (defvar pike-mode-map > - (let ((map (c-make-inherited-keymap))) > + (let ((map (make-sparse-keymap))) > ;; Additional bindings. > (define-key map "\C-c\C-e" 'c-macro-expand) > map) > @@ -1742,7 +1740,7 @@ Key bindings: > ;;;###autoload (add-to-list 'interpreter-mode-alist '("pike" . pike-mode)) > ;;;###autoload > -(define-derived-mode pike-mode prog-mode "Pike" > +(define-derived-mode pike-mode c-mode-common "Pike" > "Major mode for editing Pike code. > To submit a problem report, enter `\\[c-submit-bug-report]' from a > pike-mode buffer. This automatically sets up a mail buffer with > @@ -1757,14 +1755,11 @@ initialization, then `pike-mode-hook'. > Key bindings: > \\{pike-mode-map}" > - :after-hook (c-update-modeline) > - (c-initialize-cc-mode t) > - (setq abbrev-mode t) > (c-init-language-vars-for 'pike-mode) > (c-common-init 'pike-mode) > (easy-menu-add c-pike-menu) > ;;(cc-imenu-init cc-imenu-pike-generic-expression) ;TODO > - (c-run-mode-hooks 'c-mode-common-hook)) > + ) > ;; Support for AWK > @@ -1781,7 +1776,7 @@ Key bindings: > "Abbreviation table used in awk-mode buffers.") > (defvar awk-mode-map > - (let ((map (c-make-inherited-keymap))) > + (let ((map (make-sparse-keymap))) > ;; Add bindings which are only useful for awk. > (define-key map "#" 'self-insert-command);Overrides electric parent binding. > (define-key map "/" 'self-insert-command);Overrides electric parent binding. > @@ -1804,7 +1799,7 @@ Key bindings: > (declare-function c-awk-unstick-NL-prop "cc-awk" ()) > ;;;###autoload > -(define-derived-mode awk-mode prog-mode "AWK" > +(define-derived-mode awk-mode c-mode-common "AWK" > "Major mode for editing AWK code. > To submit a problem report, enter `\\[c-submit-bug-report]' from an > awk-mode buffer. This automatically sets up a mail buffer with version > @@ -1818,18 +1813,14 @@ initialization, then `awk-mode-hook'. > Key bindings: > \\{awk-mode-map}" > - :after-hook (c-update-modeline) > ;; We need the next line to stop the macro defining > ;; `awk-mode-syntax-table'. This would mask the real table which is > ;; declared in cc-awk.el and hasn't yet been loaded. > :syntax-table nil > (require 'cc-awk) ; Added 2003/6/10. > - (c-initialize-cc-mode t) > - (setq abbrev-mode t) > (c-init-language-vars-for 'awk-mode) > (c-common-init 'awk-mode) > - (c-awk-unstick-NL-prop) > - (c-run-mode-hooks 'c-mode-common-hook)) > + (c-awk-unstick-NL-prop)) > ;; bug reporting -- Alan Mackenzie (Nuremberg, Germany). ------------------------------------------------------------------------------ What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic patterns at an interface-level. Reveals which users, apps, and protocols are consuming the most bandwidth. Provides multi-vendor support for NetFlow, J-Flow, sFlow and other flows. Make informed decisions using capacity planning reports. https://ad.doubleclick.net/ddm/clk/305295220;132659582;e