From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.help Subject: Re: In "C" mode, how do I turn off electric mode? Date: 1 Dec 2007 00:10:38 +0100 Message-ID: <20071130224327.Q67322@colin2.muc.de> References: <47486275.1090006@gmail.com> <474B7F79.5080108@gmail.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Trace: ger.gmane.org 1196464271 25707 80.91.229.12 (30 Nov 2007 23:11:11 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 30 Nov 2007 23:11:11 +0000 (UTC) Cc: help-gnu-emacs@gnu.org To: Bruce Korb Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat Dec 01 00:11:19 2007 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1IyF0w-0001cl-AO for geh-help-gnu-emacs@m.gmane.org; Sat, 01 Dec 2007 00:11:18 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IyF0g-000588-9P for geh-help-gnu-emacs@m.gmane.org; Fri, 30 Nov 2007 18:11:02 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1IyF0P-00057j-KH for help-gnu-emacs@gnu.org; Fri, 30 Nov 2007 18:10:45 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1IyF0O-00057G-Vk for help-gnu-emacs@gnu.org; Fri, 30 Nov 2007 18:10:45 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IyF0O-000574-Q7 for help-gnu-emacs@gnu.org; Fri, 30 Nov 2007 18:10:44 -0500 Original-Received: from colin.muc.de ([193.149.48.1] helo=mail.muc.de) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1IyF0O-0006vb-6s for help-gnu-emacs@gnu.org; Fri, 30 Nov 2007 18:10:44 -0500 Original-Received: (qmail 77530 invoked by uid 3782); 30 Nov 2007 23:10:38 -0000 Original-Date: Sat, 1 Dec 2007 00:10:38 +0100 (CET) In-Reply-To: <474B7F79.5080108@gmail.com> X-detected-kernel: by monty-python.gnu.org: FreeBSD 4.6-4.9 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:49746 Archived-At: Hi again, Bruce! On Mon, 26 Nov 2007, Bruce Korb wrote: > I know I probably seem cranky. I am feeling cranky, after all. > I mean, I've used this wonderful editor for over 20 years and > it has been getting better all the time. Until I loaded version 22.1 > that came with my SuSE installation. I really do find it irritating > that I have to go find and eyeball parse this stuff: Being cranky's OK. It means that you want things set up _right_, and aren't prepared to be palmed off with rubbish. That's why a lot of people come to Emacs in the first place. Trouble is, what the "Right Thing" and "rubbish" are vary enormously from hacker to hacker. So it means you've got to put in some work to configure your own Emacs. Sometimes, this can be quite a lot of work. Let's get going! > >> ;; Safe local variables: [...snip...] > only to discover that there really does not seem to be any way > to shut up this damn "hack-local-variables-confirm" junk. > Except to rewrite the thing and have it do nothing. What a pain. > I mean, really! It is not a good interface to force all competent > users to say, "Mother, please may I?" every time some new variable > is encountered. As best I can tell from my ability meander around > this stuff, there is no other way. So, I surely hope you do not > change the name of that procedure that I am about to replace. I'd be a little more gentle on this. The file local variables mechanism is powerful enough to run arbitrary code. This means it's powerful enough for somebody to crack your machine's security just by giving you a source file and have you load it into Emacs. This could include downloading a virus or Trojan Horse from some web site. The "hack-l-v-confirm" thing is a precaution against this. It's probably worth putting up with this irritation. I'd also suggest that irritations don't add up, they multiply. So, if you get the other problems sorted out, the local variables thingy won't seem nearly as bad. Of course like you suggest, you could code your way around it if you're confident enough about the source files you'll be visiting. > And I would still like to be able to press the space bar and not > have my comment reformatted: It seems you've got Auto Fill mode enabled, somehow. Check this by looking for the word "fill" in the mode line. The purpose of this mode is _precisely_ to reformat stuff when you press the space bar. ;-) It's just that CC Mode restricts this reformatting to comments, by default, since it would be silly to fill executable code. If you've got Auto Fill on for all buffers, you could switch it off for CC Mode by putting this into your .emacs: (defun bk-cc-setup () (auto-fill-mode -1)) (add-hook 'c-mode-common-hook 'bk-cc-setup) The hooks in CC Mode are described in chapter "CC Hooks" of the CC Mode manual. This manual was completely overhauled just before Emacs 22.1 was released. It's worth a read. ;-) [ .... ] > Here is an example. I pressed "enter" and "*" and got this: > > /*=event power_fail_received > * evt-sev: debug > * evt-class: debug > * display: 'received regarding ' > * ' from node : ' > * > * arg: enum-pfail_evt_type_name, evt_type > * arg: enum-pfail_evt_type_desc, text_id > * > * arg: tpd_u32, src_node > * arg: tpd_u32, disk_id > * arg: tpd_u32, tag_type <=================== > * > =*/ OK, I'm guessing here that you pressed with point at the end of the line I've marked "<===========". Just as a matter of interest, you can type M-j to do this. (See the chapter "Filling and Breaking" in the CC Mode manual.) > Normally, I would expect the star to be "electric" and line up. So would I. But you only get this effect when "electric mode" is enabled. Have a look at your mode line: electric mode is indicated by the "l" in "C/l". Try toggling this on and off with C-c C-l, then try typing this "*" again. This is all described in Chapter "Minor Modes" in the CC Mode manual. If you got the above problem when electric mode was on, then you've found a bug. If this is the case, then to fix it, I'll need precise details of your CC Mode configuration, so that I can reproduce the failure. Would you please type C-c C-b from your C buffer, then post here the information it displays. Thanks in advance! > But I am also trying to disable electric mode because there is > simply too much magic involved. So, okay, I had to press "tab", > but it is still weird: > > > * arg: tpd_u32, tag_type > * > =*/ Post your configuration (with C-c C-b and cut and paste, as described above), then the reason this happens should become clear. > So, I move the cursor in front of the "*" character and press "space-bar": > > > * arg: tpd_u32, tag_type > > *=*/ > > and the cursor remains on the this new star, but on the next line. > There is some magical property somewhere. What nonsense is this? It looks like you've got some automatic filling function running, though I don't think it's just plain Auto Fill Mode. Maybe it says on the mode line. Could you check this out, please, and let us know? Also, this filling happens because the "=" on your comment closing line prevents CC Mode recognising the "*" as a "comment prefix". So Auto Fill Mode thinks it's just ordinary text, and it coalesces it with the line above. I'm suprised it didn't become "* =*/", though. The thing here is to tell CC Mode that your comment prefixes can have an "=" sign. Put the following into your .emacs (instead of the bit above): (defun bk-cc-setup () (auto-fill-mode -1) (setq c-comment-prefix-regexp '((pike-mode . "//+!?\\|\\**") (awk-mode . "#+") (other . "//+\\|=?\\**")))) (add-hook 'c-mode-common-hook 'bk-cc-setup) [The critical bit is the "=?" on the "other" line.] > "describe-key" says that "space-bar" is still bound to "insert-self", > but that is obviously not true. How can I do simple stuff without > resorting to X-clip/paste, changing modes to edit comments, reverting > my distribution to a back-rev emacs or just punting my favorite editor > and using VI? :( This is really way too painful. VI? That would indeed be painful. ;-) -- Alan Mackenzie (Ittersbach, Germany).