* one key-press to comment out lines of code? @ 2014-04-30 16:14 Sharon Kimble 2014-04-30 16:22 ` Drew Adams ` (5 more replies) 0 siblings, 6 replies; 27+ messages in thread From: Sharon Kimble @ 2014-04-30 16:14 UTC (permalink / raw) To: help-gnu-emacs [-- Attachment #1: Type: text/plain, Size: 740 bytes --] Whilst I'm still learning emacs and gnus I'm constantly adding code to my "setup-testbed.el" file, and then finding later that it doesn't do what its expected to do, or I don't like the outcome, so I then comment it out. Currently, I'm doing it laboriously by hand, but is it possible to highlight it and then with one key-press insert ";" in front of each and every line of the code please? I haven't seen this ability anywhere, but being able to do it would make things a whole lot easier for me, so, can it be done please folks? Sharon. -- A taste of linux = http://www.sharons.org.uk my git repo = https://bitbucket.org/boudiccas/dots TGmeds = http://www.tgmeds.org.uk Debian testing, Fluxbox 1.3.5, emacs 24.4.50.15 [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 818 bytes --] ^ permalink raw reply [flat|nested] 27+ messages in thread
* RE: one key-press to comment out lines of code? 2014-04-30 16:14 one key-press to comment out lines of code? Sharon Kimble @ 2014-04-30 16:22 ` Drew Adams 2014-04-30 17:09 ` Michael Heerdegen 2014-04-30 16:27 ` Dale Snell ` (4 subsequent siblings) 5 siblings, 1 reply; 27+ messages in thread From: Drew Adams @ 2014-04-30 16:22 UTC (permalink / raw) To: Sharon Kimble, help-gnu-emacs > Whilst I'm still learning emacs and gnus I'm constantly adding code to my > "setup-testbed.el" file, and then finding later that it doesn't do what its > expected to do, or I don't like the outcome, so I then comment it > out. Currently, I'm doing it laboriously by hand, but is it possible to > highlight it and then with one key-press insert ";" in front of each and > every > line of the code please? > > I haven't seen this ability anywhere, but being able to do it would make > things a whole lot easier for me, so, can it be done please folks? Others will no doubt tell you to use `M-;' (`comment-dwim') after selecting the text. I prefer to use `comment-region', which I bind to `C-x ;'. To uncomment, provide a plain prefix arg (`C-u'): `C-u C-x ;'. To comment using N comment chars, use a numeric prefix arg: `C-3 C-x ;'. (And you can use that to nest commented text.) ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: one key-press to comment out lines of code? 2014-04-30 16:22 ` Drew Adams @ 2014-04-30 17:09 ` Michael Heerdegen 2014-04-30 17:18 ` Michael Heerdegen 0 siblings, 1 reply; 27+ messages in thread From: Michael Heerdegen @ 2014-04-30 17:09 UTC (permalink / raw) To: help-gnu-emacs Drew Adams <drew.adams@oracle.com> writes: > Others will no doubt tell you to use `M-;' (`comment-dwim') after > selecting the text. > > I prefer to use `comment-region', which I bind to `C-x ;'. And to select the current sexp, do C-M-h. Michael. ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: one key-press to comment out lines of code? 2014-04-30 17:09 ` Michael Heerdegen @ 2014-04-30 17:18 ` Michael Heerdegen 0 siblings, 0 replies; 27+ messages in thread From: Michael Heerdegen @ 2014-04-30 17:18 UTC (permalink / raw) To: help-gnu-emacs Michael Heerdegen <michael_heerdegen@web.de> writes: > > Others will no doubt tell you to use `M-;' (`comment-dwim') after > > selecting the text. > > > > I prefer to use `comment-region', which I bind to `C-x ;'. > > And to select the current sexp, do C-M-h. BTW, another method is to just insert a quote char ' before the sexp. While it has the same effect of commenting out, this has the advantage that you can still edit the sexp normally, you can e.g. still copy parts of it to another position etc. without the need to uncomment or restore a destroyed paren structure. Michael. ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: one key-press to comment out lines of code? 2014-04-30 16:14 one key-press to comment out lines of code? Sharon Kimble 2014-04-30 16:22 ` Drew Adams @ 2014-04-30 16:27 ` Dale Snell 2014-04-30 17:38 ` Andreas Röhler ` (3 subsequent siblings) 5 siblings, 0 replies; 27+ messages in thread From: Dale Snell @ 2014-04-30 16:27 UTC (permalink / raw) To: help-gnu-emacs On Wed, 30 Apr 2014 17:14:03 +0100 Sharon Kimble <boudiccas@skimble.plus.com> wrote: > Whilst I'm still learning emacs and gnus I'm constantly adding code > to my "setup-testbed.el" file, and then finding later that it doesn't > do what its expected to do, or I don't like the outcome, so I then > comment it out. Currently, I'm doing it laboriously by hand, but is > it possible to highlight it and then with one key-press insert ";" in > front of each and every line of the code please? > > I haven't seen this ability anywhere, but being able to do it would > make things a whole lot easier for me, so, can it be done please > folks? Well, it's not precisely one keypress, but here's what I do: Set point and mark to define the region. Then do C-x r t RET ; SPC RET That should do it. If you don't like the space, you can leave it out. I like a little whitespace between my comment symbols and the program text. Hope this helps. --Dale -- "Text processing has made it possible to right-justify any idea, even one which cannot be justified on any other grounds." -- J. Finnegan, USC. ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: one key-press to comment out lines of code? 2014-04-30 16:14 one key-press to comment out lines of code? Sharon Kimble 2014-04-30 16:22 ` Drew Adams 2014-04-30 16:27 ` Dale Snell @ 2014-04-30 17:38 ` Andreas Röhler 2014-04-30 19:02 ` Stefan Monnier ` (2 subsequent siblings) 5 siblings, 0 replies; 27+ messages in thread From: Andreas Röhler @ 2014-04-30 17:38 UTC (permalink / raw) To: help-gnu-emacs On 30.04.2014 18:14, Sharon Kimble wrote: > Whilst I'm still learning emacs and gnus I'm constantly adding code to my > "setup-testbed.el" file, and then finding later that it doesn't do what its > expected to do, or I don't like the outcome, so I then comment it > out. Currently, I'm doing it laboriously by hand, but is it possible to > highlight it and then with one key-press insert ";" in front of each and every > line of the code please? > > I haven't seen this ability anywhere, but being able to do it would make > things a whole lot easier for me, so, can it be done please folks? > > Sharon. > Maybe try ar-comment-or-uncomment-lor Comment line or region, unless it's already commented: uncomment then. and available here: https://launchpad.net/s-x-emacs-werkstatt ar-comment-lor.el While this saves keystrokes and thus using this daily, nonetheless, as for Emacs beginners recommend to stay with shipped code. Also WRT to region comment-dwim is preferable - the region needs to be marked than anyway, there is not that saving. Andreas ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: one key-press to comment out lines of code? 2014-04-30 16:14 one key-press to comment out lines of code? Sharon Kimble ` (2 preceding siblings ...) 2014-04-30 17:38 ` Andreas Röhler @ 2014-04-30 19:02 ` Stefan Monnier [not found] ` <mailman.391.1398874951.1147.help-gnu-emacs@gnu.org> [not found] ` <mailman.392.1398875301.1147.help-gnu-emacs@gnu.org> 5 siblings, 0 replies; 27+ messages in thread From: Stefan Monnier @ 2014-04-30 19:02 UTC (permalink / raw) To: help-gnu-emacs > out. Currently, I'm doing it laboriously by hand, but is it possible to > highlight it and then with one key-press insert ";" in front of each and every > line of the code please? M-; Stefan ^ permalink raw reply [flat|nested] 27+ messages in thread
[parent not found: <mailman.391.1398874951.1147.help-gnu-emacs@gnu.org>]
* Re: one key-press to comment out lines of code? [not found] ` <mailman.391.1398874951.1147.help-gnu-emacs@gnu.org> @ 2014-04-30 19:03 ` Emanuel Berg 2014-04-30 20:54 ` Drew Adams [not found] ` <mailman.414.1398891311.1147.help-gnu-emacs@gnu.org> 0 siblings, 2 replies; 27+ messages in thread From: Emanuel Berg @ 2014-04-30 19:03 UTC (permalink / raw) To: help-gnu-emacs Drew Adams <drew.adams@oracle.com> writes: > Others will no doubt tell you to use `M-;' > (`comment-dwim') after selecting the text. Easy to remember! - as the Lisp comment char (the initiator for one-line comments). > I prefer to use `comment-region', which I bind to > `C-x ;'. Why not use M-; for that as well? C-SPC, move point, M-; last. > To uncomment, provide a plain prefix arg (`C-u'): > `C-u C-x ;'. To comment using N comment chars, use a > numeric prefix arg: `C-3 C-x ;'. (And you can use > that to nest commented text.) Yeah, but again, I think it is much simpler to C-SPC, move point, and M-; (if the region is commented) to uncomment. So for all three cases: M-;. Note that in all programming modes it is still M-; - so it is not M-// in C++, M-% in LaTeX, etc., or anything like that. Even if there is no commenting style defined, hit M-; and Emacs will ask you what char to use. (Though if that happens a lot, you should probably configure it for a file extension, a hash bang or something like that.) -- underground experts united: http://user.it.uu.se/~embe8573 ^ permalink raw reply [flat|nested] 27+ messages in thread
* RE: one key-press to comment out lines of code? 2014-04-30 19:03 ` Emanuel Berg @ 2014-04-30 20:54 ` Drew Adams 2014-04-30 21:06 ` Drew Adams [not found] ` <mailman.414.1398891311.1147.help-gnu-emacs@gnu.org> 1 sibling, 1 reply; 27+ messages in thread From: Drew Adams @ 2014-04-30 20:54 UTC (permalink / raw) To: Emanuel Berg, help-gnu-emacs > > I prefer to use `comment-region', which I bind to `C-x ;'. Sorry, I mistyped the key I use. I meant `C-x C-;' - hold down Control and hit `x ;' (or `u x ;', to uncomment). > Why not use M-; for that as well? C-SPC, move point, M-; last. Read what I wrote. I already said why I use `comment-region'. You are free to use anything you like. And I started out by saying that someone else would no doubt laud `M-;'. `comment-region' lets you uncomment or comment (any number of comment chars), whatever is selected (whether some or all of the selected text is already commented or not). I do also use `M-;', but only for what it has always done, even when it was bound to `indent-for-comment': add/indent inline comments. I really have no use for the rest of what it tries to do. YMMV. > > To uncomment, provide a plain prefix arg (`C-u'): > > `C-u C-x ;'. To comment using N comment chars, use a > > numeric prefix arg: `C-3 C-x ;'. (And you can use > > that to nest commented text.) > > Yeah, but again, I think it is much simpler to C-SPC, > move point, and M-; (if the region is commented) to > uncomment. You need to select the text in any case. I don't consider that `M-;' is "much simpler" than `C-x C-;'. But you can of course bind `comment-region' to whatever key you like. Or not. But no; sorry. `comment-dwim' simply does NOT do what `comment-region' does. (define-key isearch-mode-map (kbd "C-y C-a") 'foo) ;;; (define-key isearch-mode-map "\C-a" nil) Select both lines as the region. Each of `M-;' and `C-x C-;' produce this result: ;; (define-key isearch-mode-map (kbd "C-y C-a") 'foo) ;; ;;; (define-key isearch-mode-map "\C-a" nil) But `C-u C-x C-;' produces this: (define-key isearch-mode-map (kbd "C-y C-a") 'foo) (define-key isearch-mode-map "\C-a" nil) It uncomments one level. It always uncomments. `M-;' cannot uncomment the commented lines in the region when there are also uncommented lines. Now select only the second line, the one which is commented: ;;; (define-key isearch-mode-map "\C-a" nil) Now `M-;' uncomments it. `C-u C-x C-;' uncomments it too (it does so always). `C-2 M-;' removes two of the semicolons. `C-x C-;' still comments here, nesting the existing block comment, just as in the case where the selected text contained an uncommented line: ;; ;;; (define-key isearch-mode-map "\C-a" nil) And it uncomments just one level of nesting, giving this: ;;; (define-key isearch-mode-map "\C-a" nil) from this: ;; ;;; (define-key isearch-mode-map "\C-a" nil) `comment-region' does not try to outsmart you: a plain `C-u' uncomments one level. No prefix arg comments one level. A positive prefix arg comments using that many `;'. A negative prefix arg uncomments that many `;'. It is especially the behavior wrt nesting and unnesting of block comments that I appreciate. I often comment out a block of text and then comment out some more, surrounding text. Nesting of the commented lines means I can quickly unnest one level, to return to the previous state. (And yes, like the other Emacs comment functions, `comment-region' is not limited to Lisp code. `M-x' is not special in this regard.) > So for all three cases: M-;. No - see above. Most Emacs users already know about `M-;'. Far fewer know about `comment-region', which is not bound to a key by default. Which is why I mentioned it - in case it helps someone. I assumed that there are users like you who take a quick look (or no look) at `comment-region' and figure that `comment-dwim' does everything it does - everything they need. A DWIM command is often limited this way; it is a compromise. Whether `comment-dwim' is your cup of tea is up to you. ^ permalink raw reply [flat|nested] 27+ messages in thread
* RE: one key-press to comment out lines of code? 2014-04-30 20:54 ` Drew Adams @ 2014-04-30 21:06 ` Drew Adams 0 siblings, 0 replies; 27+ messages in thread From: Drew Adams @ 2014-04-30 21:06 UTC (permalink / raw) To: Emanuel Berg, help-gnu-emacs > (And yes, like the other Emacs comment functions, > `comment-region' is not limited to Lisp code. > `M-x' is not special in this regard.) ^^^ I meant `M-;', of course. ^ permalink raw reply [flat|nested] 27+ messages in thread
[parent not found: <mailman.414.1398891311.1147.help-gnu-emacs@gnu.org>]
* Re: one key-press to comment out lines of code? [not found] ` <mailman.414.1398891311.1147.help-gnu-emacs@gnu.org> @ 2014-05-01 13:54 ` Emanuel Berg 2014-05-01 14:39 ` Drew Adams [not found] ` <mailman.441.1398955214.1147.help-gnu-emacs@gnu.org> 0 siblings, 2 replies; 27+ messages in thread From: Emanuel Berg @ 2014-05-01 13:54 UTC (permalink / raw) To: help-gnu-emacs Drew Adams <drew.adams@oracle.com> writes: > `M-;' cannot uncomment the commented lines in the > region when there are also uncommented lines. Alright, nested comments! I never did that so I never thought about it. But what I can see, M-; works for those as well: ;; ;; commented-out comment into ;; commented-out comment and ;; (message "done") ; redundant comment into (message "done") ; redundant comment as well as "mulit-;" comments: ;;;; IMPORTANT into IMPORTANT Case 1 and 2 makes sense, case 3 sort of makes sense (?) but I can't visualize why you'd ever want to do that - actually it is clear it is not code so perhaps it shouldn't be uncommented. There are many use-cases for comments. I use several ; for headers, like ;;; summary (setq gnus-summary-line-format "%2{%U%} %0{%I%a%} %1{%s%}\n") (setq gnus-summary-mode-line-format "%G") Then one-liners explaining code only when it can't be deducted what the code says: (setq gnus-interactive-catchup nil) ; no confirm on catchup or the same case, but with an argument: (save-buffers-kill-terminal 1) ; don't ask, save I don't really comment-out code - but when I do, M-; always worked. What are the use-cases where M-; doesn't work? Perhaps that could be solved somehow - depends on how varied, and how advanced, those situations are, of course. > A DWIM command is often limited this way; it is a > compromise. It doesn't have to be. A DWIM command is a command with parameters just like any other, only (at least) one of those parameters are not supplied in the traditional way, instead it (or they) are extracted from the current program state. In Emacs, in my experience, the state has been related to either the existence of a region, *or* the point position and in particular the thing-at-point: if it is a URL, view it with w3m; if a file name, find-file; if a file name outside of HOME, find-file with /sudo::; etc. Now, in many cases you change (setup) the state before you invoke the DWIM command just to get a specific behaviour. So I guess that would be 50% DWIM, and 50% "provide the argument in an alternative way". But when you start using it, you never think about that distinction, of course. -- underground experts united: http://user.it.uu.se/~embe8573 ^ permalink raw reply [flat|nested] 27+ messages in thread
* RE: one key-press to comment out lines of code? 2014-05-01 13:54 ` Emanuel Berg @ 2014-05-01 14:39 ` Drew Adams [not found] ` <mailman.441.1398955214.1147.help-gnu-emacs@gnu.org> 1 sibling, 0 replies; 27+ messages in thread From: Drew Adams @ 2014-05-01 14:39 UTC (permalink / raw) To: Emanuel Berg, help-gnu-emacs > > `M-;' cannot uncomment the commented lines in the > > region when there are also uncommented lines. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > Alright, nested comments! I never did that so I never > thought about it. But what I can see, M-; works for > those as well: > > ;; ;; commented-out comment > into > ;; commented-out comment See above: "^^^^^". I already pointed out that M-; will nest. And that it will unnest, but only if the region contains only commented lines. > and > ;; (message "done") ; redundant comment > into > (message "done") ; redundant comment > as well as "mulit-;" comments: > ;;;; IMPORTANT > into > IMPORTANT See above - same story. And my previous mails about this. And the doc. And witness the behavior. > I don't really comment-out code - but when I do, M-; > always worked. > > What are the use-cases where M-; doesn't work? Perhaps > that could be solved somehow - depends on how varied, > and how advanced, those situations are, of course. See what I wrote previously. Or look at the doc of `comment-dwim' vs `comment-region'. Or experiment and see. It's not about "solving" `comment-dwim's differences. They are different on purpose, presumably. It is a compromise. If it works well enough for what you want, great. > > A DWIM command is often limited this way; it is a > > compromise. > > It doesn't have to be. It has to be. It is a guess wrt what any given user wants at any given time. Compromises can be good or bad, handy or not, depending on the algorithm, the user, and the situation. All commands are compromises, of course. Some give the user more control. `comment-dwim' doesn't give you the `comment-region' behavior and control. In my case that means it doesn't give me what I want. YMMV. ^ permalink raw reply [flat|nested] 27+ messages in thread
[parent not found: <mailman.441.1398955214.1147.help-gnu-emacs@gnu.org>]
* Re: one key-press to comment out lines of code? [not found] ` <mailman.441.1398955214.1147.help-gnu-emacs@gnu.org> @ 2014-05-01 15:03 ` Emanuel Berg 0 siblings, 0 replies; 27+ messages in thread From: Emanuel Berg @ 2014-05-01 15:03 UTC (permalink / raw) To: help-gnu-emacs Drew Adams <drew.adams@oracle.com> writes: > I already pointed out that M-; will nest. And that > it will unnest, but only if the region contains only > commented lines. OK, you mean uncomment-region will uncomment this, while M-; will comment it additionally? ;; code code Then, one has to wonder why the second line is included in the region to begin with? I guess, if you use this on big chunks of code with comments and code interleaved, it might be useful. >> > A DWIM command is often limited this way; it is a >> > compromise. >> >> It doesn't have to be. > > It has to be. It is a guess wrt what any given user > wants at any given time. Yes, but from the users' perspective they know what state gives what behaviour, so it is just an alternative way (a better, often) to tell the computer what to do. Or not having to do anything to still tell the computer that, if the state is already ripe for executing the command with a certain behaviour in mind. And if the DWIM command is good, that should happen more often than not. -- underground experts united: http://user.it.uu.se/~embe8573 ^ permalink raw reply [flat|nested] 27+ messages in thread
[parent not found: <mailman.392.1398875301.1147.help-gnu-emacs@gnu.org>]
* Re: one key-press to comment out lines of code? [not found] ` <mailman.392.1398875301.1147.help-gnu-emacs@gnu.org> @ 2014-04-30 19:10 ` Emanuel Berg 2014-04-30 20:09 ` Joost Kremers ` (2 more replies) 0 siblings, 3 replies; 27+ messages in thread From: Emanuel Berg @ 2014-04-30 19:10 UTC (permalink / raw) To: help-gnu-emacs Dale Snell <ddsnell@frontier.com> writes: > Set point and mark to define the region. Then do > > C-x r t RET ; SPC RET I'm I missing something crucial here? I think it is much better to use C-SPC, then move point, and then M-;. Meta is very close to the spacebar, where your left thumb is, and ; is right below your right little finger. Move the cursor with the super-ingrained C-e, C-n, etc., which are also short and close. And it is always the same, not just for Lisp. -- underground experts united: http://user.it.uu.se/~embe8573 ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: one key-press to comment out lines of code? 2014-04-30 19:10 ` Emanuel Berg @ 2014-04-30 20:09 ` Joost Kremers 2014-05-01 14:15 ` Emanuel Berg 2014-04-30 21:12 ` Dale Snell [not found] ` <mailman.417.1398892388.1147.help-gnu-emacs@gnu.org> 2 siblings, 1 reply; 27+ messages in thread From: Joost Kremers @ 2014-04-30 20:09 UTC (permalink / raw) To: help-gnu-emacs Emanuel Berg wrote: > Dale Snell <ddsnell@frontier.com> writes: > >> Set point and mark to define the region. Then do >> >> C-x r t RET ; SPC RET > > I think it is much better to use C-SPC, then move > point, and then M-;. True. But knowing about `string-rectangle` is a good thing. You never know when you find yourself in an Emacs challenge competition and you have to comment out a region without using `comment-region` or `comment-dwim`. ;-) -- Joost Kremers joostkremers@fastmail.fm Selbst in die Unterwelt dringt durch Spalten Licht EN:SiS(9) ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: one key-press to comment out lines of code? 2014-04-30 20:09 ` Joost Kremers @ 2014-05-01 14:15 ` Emanuel Berg 2014-05-01 14:31 ` Joost Kremers 0 siblings, 1 reply; 27+ messages in thread From: Emanuel Berg @ 2014-05-01 14:15 UTC (permalink / raw) To: help-gnu-emacs Joost Kremers <joost.m.kremers@gmail.com> writes: > True. But knowing about `string-rectangle` is a good > thing. You never know when you find yourself in an > Emacs challenge competition and you have to comment > out a region without using `comment-region` or > `comment-dwim`. ;-) Always: the more knowledge the better. At least for knowledge that can be applied (skill or capability are perhaps better words). Are there really Emacs challenge competitions? I can't say I'm attracted to that because though I always want to do things with speed, I never want to be stressed, with deadlines, people shouting and being frustrated, etc. I'll save those juices for a real crisis (like a fire or whatever). But it would be interesting to watch if such an Emacs challenge has been recorded and made available for example on YT. -- underground experts united: http://user.it.uu.se/~embe8573 ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: one key-press to comment out lines of code? 2014-05-01 14:15 ` Emanuel Berg @ 2014-05-01 14:31 ` Joost Kremers 0 siblings, 0 replies; 27+ messages in thread From: Joost Kremers @ 2014-05-01 14:31 UTC (permalink / raw) To: help-gnu-emacs Emanuel Berg wrote: > Are there really Emacs challenge competitions? Not that I know of... That was just a joke. ;-) -- Joost Kremers joostkremers@fastmail.fm Selbst in die Unterwelt dringt durch Spalten Licht EN:SiS(9) ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: one key-press to comment out lines of code? 2014-04-30 19:10 ` Emanuel Berg 2014-04-30 20:09 ` Joost Kremers @ 2014-04-30 21:12 ` Dale Snell [not found] ` <mailman.417.1398892388.1147.help-gnu-emacs@gnu.org> 2 siblings, 0 replies; 27+ messages in thread From: Dale Snell @ 2014-04-30 21:12 UTC (permalink / raw) To: help-gnu-emacs On Wed, 30 Apr 2014 21:10:43 +0200 Emanuel Berg <embe8573@student.uu.se> wrote: > Dale Snell <ddsnell@frontier.com> writes: > > > Set point and mark to define the region. Then do > > > > C-x r t RET ; SPC RET > > I'm I missing something crucial here? Not really; this is just how I usually do that sort of thing. I first heard of M-; from this mailing list. Alas, when it comes time to (un-)comment a section of code or whatever, I never remember it. :-) The rectangle commands are kinda ingrained into my fingers. > I think it is much better to use C-SPC, then move > point, and then M-;. Meta is very close to the > spacebar, where your left thumb is, and ; is right > below your right little finger. Move the cursor with > the super-ingrained C-e, C-n, etc., which are also > short and close. And it is always the same, not just > for Lisp. On your keyboard, perhaps. Mine's set up a bit differently (the "Windows" keys are the Meta keys, the Alt keys, on either side of the space bar, are the Alt keys.) This makes folding my thumbs a bit awkward. Also, since I often run Emacs in a terminal window, I wind up using the escape key as the Meta prefix. I've been doing that since the '80s (I started with Gosling Emacs on a Pyramid computer), so I'm unlikely to change my ways at this late date. :-) I'm happy with my slightly-less-efficient method. You've got your more-efficient method, and you're obviously happy with it. As has been said, there's more than one way to stack a cat. Happy Emacsing, --Dale -- "If one would give me six lines written by the hand of the most honest man, I would find something in them to have him hanged." -- Cardinal Richelieu ^ permalink raw reply [flat|nested] 27+ messages in thread
[parent not found: <mailman.417.1398892388.1147.help-gnu-emacs@gnu.org>]
* Re: one key-press to comment out lines of code? [not found] ` <mailman.417.1398892388.1147.help-gnu-emacs@gnu.org> @ 2014-05-01 14:05 ` Emanuel Berg 2014-05-01 22:54 ` Dale Snell [not found] ` <mailman.469.1398984898.1147.help-gnu-emacs@gnu.org> 0 siblings, 2 replies; 27+ messages in thread From: Emanuel Berg @ 2014-05-01 14:05 UTC (permalink / raw) To: help-gnu-emacs Dale Snell <ddsnell@frontier.com> writes: > On your keyboard, perhaps. Mine's set up a bit > differently (the "Windows" keys are the Meta keys, > the Alt keys, on either side of the space bar, are > the Alt keys.) Interesting. I have a keyboard from Sun. Turns out, it says "Alt" on the Meta key, but it has the Meta key behaviour and I don't remember configuring that. > This makes folding my thumbs a bit awkward. Also, > since I often run Emacs in a terminal window, I wind > up using the escape key as the Meta prefix. I run Emacs in a Linux VT (a tty, or "the console") but the Meta key works fine. As for Esc I have that to the left of F1 (in the normal place I would assume) so that would be a pain having to move the left hand from typing position all the time. I think (and someone on this list confirmed this with a cool image) that the Esc solution for Emacs has historical roots when the paleo-keyboards had Esc somewhere else. (Get back to you on this when I find that old post.) But perhaps you re-routed Esc for Caps Lock? > I'm happy with my slightly-less-efficient method. > You've got your more-efficient method, and you're > obviously happy with it. As has been said, there's > more than one way to stack a cat. Absolutely positively. -- underground experts united: http://user.it.uu.se/~embe8573 ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: one key-press to comment out lines of code? 2014-05-01 14:05 ` Emanuel Berg @ 2014-05-01 22:54 ` Dale Snell [not found] ` <mailman.469.1398984898.1147.help-gnu-emacs@gnu.org> 1 sibling, 0 replies; 27+ messages in thread From: Dale Snell @ 2014-05-01 22:54 UTC (permalink / raw) To: help-gnu-emacs On Thu, 01 May 2014 16:05:21 +0200 Emanuel Berg <embe8573@student.uu.se> wrote: > Dale Snell <ddsnell@frontier.com> writes: > > On your keyboard, perhaps. Mine's set up a bit > > differently (the "Windows" keys are the Meta keys, > > the Alt keys, on either side of the space bar, are > > the Alt keys.) > > Interesting. I have a keyboard from Sun. Turns out, it > says "Alt" on the Meta key, but it has the Meta key > behaviour and I don't remember configuring that. You probably didn't. In my experience, most personal computer OSs map Meta and Alt together on the same keys. So you wouldn't notice unless you needed both alt and meta variations of the same character. Fortunately, such mappings can be repaired, if needed. > [...] I think (and someone on > this list confirmed this with a cool image) that the > Esc solution for Emacs has historical roots when the > paleo-keyboards had Esc somewhere else. (Get back to > you on this when I find that old post.) Heh, yeah, the old terminals had keys wandering all over the place. Every manufacturer had a different idea of where things like escape, |, \, `, ~, and so on belonged. Sometimes they would change their minds from one model to the next. As I recall, the DEC VT-101 that I learned Emacs on had the escape key where the `/~ usually is now. The `/~ key was between the =/+ and backspace keys, and the |/\ key was to the right of the return key. (An awful place. One had to be careful if one used those characters.) > But perhaps you re-routed Esc for Caps Lock? No, I swapped control for caps-lock, putting the control key next to the A key, where it's much more accessible. Since I seldom use the caps-lock function, it doesn't bother me that said key was relegated to the second most inconvenient place on the keyboard. (The most inconvenient position, imnsho, is the right control key. Next to the left arrow key. Ugh.) --Dale -- Q: Why did the Klingon color his hair blond? A: Because it was a good day to dye. ^ permalink raw reply [flat|nested] 27+ messages in thread
[parent not found: <mailman.469.1398984898.1147.help-gnu-emacs@gnu.org>]
* Re: one key-press to comment out lines of code? [not found] ` <mailman.469.1398984898.1147.help-gnu-emacs@gnu.org> @ 2014-05-01 23:42 ` Emanuel Berg 2014-05-02 0:11 ` Joost Kremers ` (2 more replies) 0 siblings, 3 replies; 27+ messages in thread From: Emanuel Berg @ 2014-05-01 23:42 UTC (permalink / raw) To: help-gnu-emacs Dale Snell <ddsnell@frontier.com> writes: > Heh, yeah, the old terminals had keys wandering all > over the place. Every manufacturer had a different > idea of where things like escape, |, \, `, ~, and so > on belonged. Sometimes they would change their minds > from one model to the next. As I recall, the DEC > VT-101 that I learned Emacs on had the escape key > where the /~ usually is now. The `/~ key was between > the =/+ and backspace keys, and the |/\ key was to > the right of the return key. (An awful place. One > had to be careful if one used those characters.) Cool. I found the old exchange: YT: ... was the Escape key placed anywhere else than it is on today's keyboards? The reason I ask is - well, just try hitting a couple of familiar shortcuts, but instead of Meta, use Escape. I think it would take a master at the accordion to be productive using that. Bob Proulx: Yes. The escape key has been located in other locations. Here is an example. On the HP HIL keyboard it was left of the left shift key. (Also note that control was left of the A.) A good keyboard layout for the touch typist. Everything was relatively close to the home row. http://www.hpmuseum.net/display_item.php?hw=575 Mostly escape has been located in the upper left "somewhere". Although not always left of the 1 key. >> But perhaps you re-routed Esc for Caps Lock? > > No, I swapped control for caps-lock, putting the > control key next to the A key, where it's much more > accessible. Yeah, I've heard a lot of people doing that. I actually think left control is kind of close and good for the left little finger. Caps-lock is better, yes, but is it better enough to make it worthwhile to re-learn? Don't know. > Since I seldom use the caps-lock function, it doesn't > bother me that said key was relegated to the second > most inconvenient place on the keyboard. I have an Emacs-only software solution for upper-case only mode (which I get with <M-caps>). It is based on caps-mode.el but I put some changes there, namely it maps dashes to underscores, and, it disables itself on a non-alphanumeric (or dash/underscore) keystroke (i.e., most often a whitespace). It works great in Emacs but I wish I could get it in zsh as well. There is still the acronyms (e.g., URL), and even more so the non-computer files (README) and environmentals (HOME), and I'd like a caps-lock for that. Instead I bring up the buffer-menu (files only) on the caps-lock key (only) in Emacs, and once there, an additional stroke of caps-lock brings up all files. So I can toggle all I want. Pretty clever! But there should be one million things to do with the caps-lock key that is more sensible than changing the case... > (The most inconvenient position, imnsho, is the right > control key. Next to the left arrow key. Ugh.) Agreed. I actually don't have it. To the right of the space bar, I have "Alt Graph" (which is Meta as well, it seems), then a key with a solid diamond (seems to be escape), and then "Compose Key" which doesn't seem to do anything. (I actually have the compose key somewhere else.) But: why are those keys so inconvenient? What's stopping from using them as the control and Meta on the left side? They are just one centimeter too far to the right and that does it. -- underground experts united: http://user.it.uu.se/~embe8573 ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: one key-press to comment out lines of code? 2014-05-01 23:42 ` Emanuel Berg @ 2014-05-02 0:11 ` Joost Kremers 2014-05-02 1:23 ` Emanuel Berg 2014-05-03 2:01 ` Emanuel Berg 2014-05-02 17:42 ` Dale Snell [not found] ` <mailman.520.1399052563.1147.help-gnu-emacs@gnu.org> 2 siblings, 2 replies; 27+ messages in thread From: Joost Kremers @ 2014-05-02 0:11 UTC (permalink / raw) To: help-gnu-emacs Emanuel Berg wrote: > It works great in Emacs but I wish I could get it in > zsh as well. There is still the acronyms (e.g., URL), url M-- M-u Also works in bash. Perhaps zsh as well? -- Joost Kremers joostkremers@fastmail.fm Selbst in die Unterwelt dringt durch Spalten Licht EN:SiS(9) ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: one key-press to comment out lines of code? 2014-05-02 0:11 ` Joost Kremers @ 2014-05-02 1:23 ` Emanuel Berg 2014-05-03 2:01 ` Emanuel Berg 1 sibling, 0 replies; 27+ messages in thread From: Emanuel Berg @ 2014-05-02 1:23 UTC (permalink / raw) To: help-gnu-emacs Joost Kremers <joost.m.kremers@gmail.com> writes: > url M-- M-u > > Also works in bash. Perhaps zsh as well? I have M-u to switch from the console to X, and then back, so I had to kill xbindkeys to try this - keys... they make you insane - and yes! that works in bash, but not in zsh. I'm sure it works somehow in zsh, though, they always brag about their sweet features. But I'd like it the other way around: the command *before* the word - still it is better than holding down shift while typing. OK, I'll find out. -- underground experts united: http://user.it.uu.se/~embe8573 ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: one key-press to comment out lines of code? 2014-05-02 0:11 ` Joost Kremers 2014-05-02 1:23 ` Emanuel Berg @ 2014-05-03 2:01 ` Emanuel Berg 2014-05-03 2:43 ` Emanuel Berg 1 sibling, 1 reply; 27+ messages in thread From: Emanuel Berg @ 2014-05-03 2:01 UTC (permalink / raw) To: help-gnu-emacs Joost Kremers <joost.m.kremers@gmail.com> writes: > url M-- M-u > > Also works in bash. Perhaps zsh as well? 1.5 corrections to my previous post: * M-u does work in zsh: it uppercases the following word. M-- doesn't seem to do the same in bash and zsh, though, so that doesn't work - but the functionality is probably just bound to some other key in zsh. However, M-b (instead of M--) and then M-u work (M-b as in backward-word, just as in Emacs). * M-x is of course not a prefix key - that should be C-x (or C-c). -- underground experts united: http://user.it.uu.se/~embe8573 ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: one key-press to comment out lines of code? 2014-05-03 2:01 ` Emanuel Berg @ 2014-05-03 2:43 ` Emanuel Berg 0 siblings, 0 replies; 27+ messages in thread From: Emanuel Berg @ 2014-05-03 2:43 UTC (permalink / raw) To: help-gnu-emacs > M-u does work in zsh: it uppercases the following > word. M-- doesn't seem to do the same in bash and > zsh, though, so that doesn't work - but the > functionality is probably just bound to some other > key in zsh. However, M-b (instead of M--) and then > M-u work (M-b as in backward-word, just as in Emacs). Made it work like this: upcase-previous () { zle backward-word zle up-case-word } zle -N upcase-previous bindkey Ē upcase-previous Ē is the key the VT sends on <M-caps>, which puts Emacs in caps-mode - so here, I can use the same key to upcase the last word - it is not as good as in Emacs, because for a split second you see the "incorrect" filename, and you type it, and that might bite you later if you do it too much - but still sort of cool. Wow, I'm certainly happy I had this discussion with you, otherwise I wouldn't have thought of looking this up. -- underground experts united: http://user.it.uu.se/~embe8573 ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: one key-press to comment out lines of code? 2014-05-01 23:42 ` Emanuel Berg 2014-05-02 0:11 ` Joost Kremers @ 2014-05-02 17:42 ` Dale Snell [not found] ` <mailman.520.1399052563.1147.help-gnu-emacs@gnu.org> 2 siblings, 0 replies; 27+ messages in thread From: Dale Snell @ 2014-05-02 17:42 UTC (permalink / raw) To: help-gnu-emacs On Fri, 02 May 2014 01:42:23 +0200 Emanuel Berg <embe8573@student.uu.se> wrote: > Dale Snell <ddsnell@frontier.com> writes: > > > Heh, yeah, the old terminals had keys wandering all > > over the place. Every manufacturer had a different > > idea of where things like escape, |, \, `, ~, and so > > on belonged. Sometimes they would change their minds > > from one model to the next. As I recall, the DEC > > VT-101 that I learned Emacs on had the escape key > > where the /~ usually is now. The `/~ key was between > > the =/+ and backspace keys, and the |/\ key was to > > the right of the return key. (An awful place. One > > had to be careful if one used those characters.) > > Cool. I found the old exchange: > > YT: > > ... was the Escape key placed anywhere else than it is > on today's keyboards? The reason I ask is - well, just > try hitting a couple of familiar shortcuts, but instead > of Meta, use Escape. I think it would take a master at > the accordion to be productive using that. > > Bob Proulx: > > Yes. The escape key has been located in other > locations. Here is an example. On the HP HIL keyboard > it was left of the left shift key. (Also note that > control was left of the A.) A good keyboard layout for > the touch typist. Everything was relatively close to > the home row. > > http://www.hpmuseum.net/display_item.php?hw=575 > > Mostly escape has been located in the upper left > "somewhere". Although not always left of the 1 key. > > >> But perhaps you re-routed Esc for Caps Lock? > > > > No, I swapped control for caps-lock, putting the > > control key next to the A key, where it's much more > > accessible. > > Yeah, I've heard a lot of people doing that. I actually > think left control is kind of close and good for the > left little finger. Caps-lock is better, yes, but is it > better enough to make it worthwhile to re-learn? Don't > know. For me, the position of the control key next to the A key is far more convenient than the default in the lower-left-hand corner. Besides, my fingers are trained for that position. Every time I use an un-modified keyboard, it drives me buggy. Plus, that lower-left corner is far enough from the home row that I have to take my left hand off the keys. > [...] But there > should be one million things to do with the caps-lock > key that is more sensible than changing the case... One idea I've been tossing around is to turn the caps lock into a "super" or "hyper" modifier key. Then change the right-hand control key into the opposite. Those modifiers aren't used much, if at all, but Emacs will respond to them. That would give me a lot more key-chords I could tie to functions that are normally un-bound. > > (The most inconvenient position, imnsho, is the right > > control key. Next to the left arrow key. Ugh.) > > Agreed. I actually don't have it. To the right of the > space bar, I have "Alt Graph" (which is Meta as well, > it seems), then a key with a solid diamond (seems to be > escape), and then "Compose Key" which doesn't seem to > do anything. (I actually have the compose key somewhere > else.) But: why are those keys so inconvenient? What's > stopping from using them as the control and Meta on the > left side? They are just one centimeter too far to the > right and that does it. Ooh, I *liked* the old Sun keyboards. It's been a long time since I used a Sun, but I think the diamond key was a sort of "command" key, like on an Apple Mac. (When I was using a Sun, it was a Sun Three, with dual 68020 CPUs running at 20MHz. And we thought it was great! Ah, how times have changed. :-) ) But yes, I can understand your frustration with the keyboard layout. The only thing I can suggest is re-mapping the keys to be what you want, where you want. As much a physically possible, at any rate. --Dale -- "Don't only practice your Art, but force your way into its Secrets, for it and Knowledge can raise Men to the Divine." -- Ludwig van Beethoven ^ permalink raw reply [flat|nested] 27+ messages in thread
[parent not found: <mailman.520.1399052563.1147.help-gnu-emacs@gnu.org>]
* Re: one key-press to comment out lines of code? [not found] ` <mailman.520.1399052563.1147.help-gnu-emacs@gnu.org> @ 2014-05-02 19:59 ` Emanuel Berg 0 siblings, 0 replies; 27+ messages in thread From: Emanuel Berg @ 2014-05-02 19:59 UTC (permalink / raw) To: help-gnu-emacs Dale Snell <ddsnell@frontier.com> writes: > For me, the position of the control key next to the A > key is far more convenient than the default in the > lower-left-hand corner. Yes, I agree it is better, only I have so much stuff in my muscle-memory: - the (left) control key - the caps-lock key once or twice (buffer-menu: files-only/all-buffers) - <M-caps> for the buffer-local caps-mode - <shift-caps> for dired-jump (right shift, though both works) So if I were to switch to the better solution now, there would be chaos for a while :) > Besides, my fingers are trained for that position. > Every time I use an un-modified keyboard, it drives > me buggy. Plus, that lower-left corner is far enough > from the home row that I have to take my left hand > off the keys. Aha! In that case it really sucks. No, I can hit the left control with the left-hand little finger while the left-hand index finger remains at F. > Ooh, I *liked* the old Sun keyboards. It's been a > long time since I used a Sun, but I think the diamond > key was a sort of "command" key, like on an Apple > Mac. (When I was using a Sun, it was a Sun Three, > with dual 68020 CPUs running at 20MHz. And we > thought it was great! Ah, how times have > changed. :-) ) But yes, I can understand your > frustration with the keyboard layout. The only thing > I can suggest is re-mapping the keys to be what you > want, where you want. As much a physically possible, > at any rate. Yeah, I've done that a lot, and I'm not actually frustrated about keys because they can be quite pleasant to fiddle around with, but it sure took its fair amount of time. I never thought of the hyper/super modifier, instead I setup C-o to be a new prefix key (much like M-x). I actually think C-o is better than M-x (because it involves both hands) but both are good. Best would be M and then either J, K, L or ; but (you guessed it) I have those since long for other things... -- underground experts united: http://user.it.uu.se/~embe8573 ^ permalink raw reply [flat|nested] 27+ messages in thread
end of thread, other threads:[~2014-05-03 2:43 UTC | newest] Thread overview: 27+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2014-04-30 16:14 one key-press to comment out lines of code? Sharon Kimble 2014-04-30 16:22 ` Drew Adams 2014-04-30 17:09 ` Michael Heerdegen 2014-04-30 17:18 ` Michael Heerdegen 2014-04-30 16:27 ` Dale Snell 2014-04-30 17:38 ` Andreas Röhler 2014-04-30 19:02 ` Stefan Monnier [not found] ` <mailman.391.1398874951.1147.help-gnu-emacs@gnu.org> 2014-04-30 19:03 ` Emanuel Berg 2014-04-30 20:54 ` Drew Adams 2014-04-30 21:06 ` Drew Adams [not found] ` <mailman.414.1398891311.1147.help-gnu-emacs@gnu.org> 2014-05-01 13:54 ` Emanuel Berg 2014-05-01 14:39 ` Drew Adams [not found] ` <mailman.441.1398955214.1147.help-gnu-emacs@gnu.org> 2014-05-01 15:03 ` Emanuel Berg [not found] ` <mailman.392.1398875301.1147.help-gnu-emacs@gnu.org> 2014-04-30 19:10 ` Emanuel Berg 2014-04-30 20:09 ` Joost Kremers 2014-05-01 14:15 ` Emanuel Berg 2014-05-01 14:31 ` Joost Kremers 2014-04-30 21:12 ` Dale Snell [not found] ` <mailman.417.1398892388.1147.help-gnu-emacs@gnu.org> 2014-05-01 14:05 ` Emanuel Berg 2014-05-01 22:54 ` Dale Snell [not found] ` <mailman.469.1398984898.1147.help-gnu-emacs@gnu.org> 2014-05-01 23:42 ` Emanuel Berg 2014-05-02 0:11 ` Joost Kremers 2014-05-02 1:23 ` Emanuel Berg 2014-05-03 2:01 ` Emanuel Berg 2014-05-03 2:43 ` Emanuel Berg 2014-05-02 17:42 ` Dale Snell [not found] ` <mailman.520.1399052563.1147.help-gnu-emacs@gnu.org> 2014-05-02 19:59 ` Emanuel Berg
Code repositories for project(s) associated with this external index https://git.savannah.gnu.org/cgit/emacs.git https://git.savannah.gnu.org/cgit/emacs/org-mode.git This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.