bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#64104: Subject: 30.0.50; uncomment-region-default-1


From: Andreas Röhler
Subject: bug#64104: Subject: 30.0.50; uncomment-region-default-1
Date: Sun, 18 Jun 2023 15:00:19 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0


Am 18.06.23 um 07:53 schrieb Eli Zaretskii:
From: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: Andreas Röhler <andreas.roehler@easy-emacs.de>,
   64104@debbugs.gnu.org
Date: Sat, 17 Jun 2023 14:39:08 -0400

C-u comment-dwim RET with an active region of the following Python code:

---
# for i in text:
#     print("(i): {}".format(str(i)))
---

results in error saying

uncomment-region-default-1: Beginning of buffer
Stefan, any comments?
- The error we give is not very user-friendly, so it might be good to
   catch it and re-raise it as something more meaning ful the specific
   operation performed.

- I have the vague impression that in some earlier version of that code we
   would not signal an error but just remove as many comment markers as
   possible (but no more than requested).
   That could be a more friendly behavior.
I'll leave the bug open, then.  Patches to improve this command are
welcome.


Unfortunately don't have a trivial fix.

Suggest a simplified caller:

(defun comment-dwim (arg)
  "Call the comment command you want (Do What I Mean).

Comment or uncomment the current line, or, if active, the region.

With \\[universal-argument] copy line or region before changing it.

You can configure `comment-style' to change the way regions are commented."
  (interactive "*P")
  (comment-normalize-vars)
  (when (eq 4 (prefix-numeric-value))
    (copy-region-as-kill (or (region-beginning) (line-beginning-position)) (or (region-end) (line-end-position))))   (comment-or-uncomment-region (or (region-beginning) (line-beginning-position)) (or (region-end)) (line-end-position)))








reply via email to

[Prev in Thread] Current Thread [Next in Thread]