* In "C" mode, how do I turn off electric mode? @ 2007-11-24 17:42 Bruce Korb 2007-11-24 20:04 ` Eli Zaretskii ` (2 more replies) 0 siblings, 3 replies; 6+ messages in thread From: Bruce Korb @ 2007-11-24 17:42 UTC (permalink / raw) To: help-gnu-emacs c-toggle-electric-state does not seem to do the trick. I try to put text into a comment, and the electric mode is so helpful, it is impossible to do it, except by using text mode in another buffer and pasting it into my C code. What is going on? What are the emacs developers thinking? STOP BEING SO HELPFUL. IT IS NOT HELPFUL. I JUST WANT TO EDIT MY TEXT. SOME ASSISTS ARE NICE BUT THIS IS WAY OVER THE LINE. ARGHHHH!!!!!!!!!!! ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: In "C" mode, how do I turn off electric mode? 2007-11-24 17:42 In "C" mode, how do I turn off electric mode? Bruce Korb @ 2007-11-24 20:04 ` Eli Zaretskii 2007-11-24 21:18 ` Alan Mackenzie 2007-11-27 2:22 ` Bruce Korb 2 siblings, 0 replies; 6+ messages in thread From: Eli Zaretskii @ 2007-11-24 20:04 UTC (permalink / raw) To: help-gnu-emacs > Date: Sat, 24 Nov 2007 09:42:13 -0800 > From: Bruce Korb <Bruce.Korb@gmail.com> > > c-toggle-electric-state > > does not seem to do the trick. What trick is that? Please describe what features of C Mode you'd like to turn off; we cannot be expected to guess that. > What is going on? What are the emacs developers thinking? > STOP BEING SO HELPFUL. IT IS NOT HELPFUL. I JUST WANT TO EDIT > MY TEXT. SOME ASSISTS ARE NICE BUT THIS IS WAY OVER THE LINE. > ARGHHHH!!!!!!!!!!! If you are so annoyed by C-specific electricity, perhaps you should use Text Mode for editing C sources. That can be done by customizing auto-mode-alist. ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: In "C" mode, how do I turn off electric mode? 2007-11-24 17:42 In "C" mode, how do I turn off electric mode? Bruce Korb 2007-11-24 20:04 ` Eli Zaretskii @ 2007-11-24 21:18 ` Alan Mackenzie 2007-11-27 2:22 ` Bruce Korb 2 siblings, 0 replies; 6+ messages in thread From: Alan Mackenzie @ 2007-11-24 21:18 UTC (permalink / raw) To: Bruce Korb; +Cc: help-gnu-emacs Hi, Bruce! On Sat, Nov 24, 2007 at 09:42:13AM -0800, Bruce Korb wrote: > c-toggle-electric-state does not seem to do the trick. I try to put > text into a comment, and the electric mode is so helpful, it is > impossible to do it, except by using text mode in another buffer and > pasting it into my C code. OK, calm down please! We'll get your CC Mode working reasonably for you, don't worry! All "helpful" features in CC Mode can be turned off. Have you got the latest version of Emacs/CC Mode? If you do M-x c-version, you should hopefully get 5.31.n, where n is probably 4. If not, you might want to upgrade your Emacs. And just to make sure we're speaking the same language: "electric mode" in CC Mode means things like your code being automatically re-indented when you type a semicolon or brace. You can toggle this with C-c C-l. See the page "Getting Started" in the CC Mode manual if you want to disable it more permanently. The page "Electric Keys" gives a complete run down of the electric mode. > What is going on? What are the emacs developers thinking? > STOP BEING SO HELPFUL. Hey, I don't think you mean that! I'm being as helpful as I can, right now. ;-) > IT IS NOT HELPFUL. I JUST WANT TO EDIT MY TEXT. SOME ASSISTS ARE NICE > BUT THIS IS WAY OVER THE LINE. ARGHHHH!!!!!!!!!!! Really, these things _are_ helpful. Honest! The problem is that you don't feel in control of what Emacs is doing. So the way to go is to disable the particular features which are biting, and once you feel like you've got control back again, you can then start experimenting with them slowly, if you want. You might even like them if they're not being forced on you. We need to identify these features. You've said: > I try to put text into a comment, and the electric mode is so helpful, > it is impossible to do it, except by using text mode in another buffer > and pasting it into my C code. Could you please give as a keystroke-by-keystroke description of what you're doing and what you see: o - Is it an existing comment or a new one? o - If it's new, how did you create it? o - How are you putting the text into the comment? Typing a character at a time, or with C-y, or how? o - What happens, and what do you want to happen instead? Have you configured any CC Mode stuff in your .emacs? If so, would you post the relevant bits here, please. -- Alan Mackenzie (Ittersbach, Germany). ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: In "C" mode, how do I turn off electric mode? 2007-11-24 17:42 In "C" mode, how do I turn off electric mode? Bruce Korb 2007-11-24 20:04 ` Eli Zaretskii 2007-11-24 21:18 ` Alan Mackenzie @ 2007-11-27 2:22 ` Bruce Korb 2007-11-27 12:42 ` Peter Dyballa 2007-11-30 23:10 ` Alan Mackenzie 2 siblings, 2 replies; 6+ messages in thread From: Bruce Korb @ 2007-11-27 2:22 UTC (permalink / raw) To: Bruce Korb; +Cc: help-gnu-emacs 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: > ;; Safe local variables: > ;; > ;; For variables defined by major modes, the safety declarations can go into > ;; the major mode's file, since that will be loaded before file variables are > ;; processed. > ;; > ;; For variables defined by minor modes, put the safety declarations in the > ;; file defining the minor mode after the defcustom/defvar using an autoload > ;; cookie, e.g.: > ;; > ;; ;;;###autoload(put 'variable 'safe-local-variable 'stringp) > ;; > ;; Otherwise, when Emacs visits a file specifying that local variable, the > ;; minor mode file may not be loaded yet. > ;; > ;; For variables defined in the C source code the declaration should go here: > > (mapc (lambda (pair) > (put (car pair) 'safe-local-variable (cdr pair))) > '((buffer-read-only . booleanp) ;; C source code > (default-directory . stringp) ;; C source code > (fill-column . integerp) ;; C source code > (indent-tabs-mode . booleanp) ;; C source code > (left-margin . integerp) ;; C source code > (no-update-autoloads . booleanp) > (tab-width . integerp) ;; C source code > (truncate-lines . booleanp))) ;; C source code > > (put 'c-set-style 'safe-local-eval-function t) > > (defun hack-local-variables-confirm (vars unsafe-vars risky-vars) > (if noninteractive > nil > (let ((name (if buffer-file-name 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. And I would still like to be able to press the space bar and not have my comment reformatted: Bruce Korb wrote: > c-toggle-electric-state > > does not seem to do the trick. I try to put text into a comment, > and the electric mode is so helpful, it is impossible to do it, except > by using text mode in another buffer and pasting it into my C code. > What is going on? What are the emacs developers thinking? > STOP BEING SO HELPFUL. IT IS NOT HELPFUL. I JUST WANT TO EDIT > MY TEXT. SOME ASSISTS ARE NICE BUT THIS IS WAY OVER THE LINE. > ARGHHHH!!!!!!!!!!! Here is an example. I pressed "enter" and "*" and got this: /*=event power_fail_received * evt-sev: debug * evt-class: debug * display: 'received <evt_type> regarding <disk_id>' * ' from node <src_node>: <text_id>' * * 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 * =*/ Normally, I would expect the star to be "electric" and line up. 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 * =*/ 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? "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. ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: In "C" mode, how do I turn off electric mode? 2007-11-27 2:22 ` Bruce Korb @ 2007-11-27 12:42 ` Peter Dyballa 2007-11-30 23:10 ` Alan Mackenzie 1 sibling, 0 replies; 6+ messages in thread From: Peter Dyballa @ 2007-11-27 12:42 UTC (permalink / raw) To: Bruce Korb; +Cc: help-gnu-emacs Am 27.11.2007 um 03:22 schrieb Bruce Korb: > 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? Correct load-path? I didn't understand your whole message, maybe you encounter a Suse/Novell service. So I'd recommend to set a sensible EMACSLOADPATH in environment that omits the unwanted service. -- Greetings Pete "If we don't succeed, we run the risk of failure." George W. Bush ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: In "C" mode, how do I turn off electric mode? 2007-11-27 2:22 ` Bruce Korb 2007-11-27 12:42 ` Peter Dyballa @ 2007-11-30 23:10 ` Alan Mackenzie 1 sibling, 0 replies; 6+ messages in thread From: Alan Mackenzie @ 2007-11-30 23:10 UTC (permalink / raw) To: Bruce Korb; +Cc: help-gnu-emacs 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 <evt_type> regarding <disk_id>' > * ' from node <src_node>: <text_id>' > * > * 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 <enter> 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). ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2007-11-30 23:10 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2007-11-24 17:42 In "C" mode, how do I turn off electric mode? Bruce Korb 2007-11-24 20:04 ` Eli Zaretskii 2007-11-24 21:18 ` Alan Mackenzie 2007-11-27 2:22 ` Bruce Korb 2007-11-27 12:42 ` Peter Dyballa 2007-11-30 23:10 ` Alan Mackenzie
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).