all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Emanuel Berg <embe8573@student.uu.se>
To: help-gnu-emacs@gnu.org
Subject: Re: one key-press to comment out lines of code?
Date: Thu, 01 May 2014 15:54:31 +0200	[thread overview]
Message-ID: <87ha59ioyw.fsf@nl106-137-194.student.uu.se> (raw)
In-Reply-To: mailman.414.1398891311.1147.help-gnu-emacs@gnu.org

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


  parent reply	other threads:[~2014-05-01 13:54 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87ha59ioyw.fsf@nl106-137-194.student.uu.se \
    --to=embe8573@student.uu.se \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.