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

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

RE: finding the hork point in ~/.emacs


From: Drew Adams
Subject: RE: finding the hork point in ~/.emacs
Date: Wed, 26 Aug 2020 21:57:28 -0700 (PDT)

> ? `comment-dwim':
> 
>   If the region is active and ‘transient-mark-mode’
>   is on, call ‘comment-region’ (unless it only
>   consists of comments, in which case it calls
>   ‘uncomment-region’).

Right: "unless it..."

I want it to comment when I tell it to comment,
including when it may already be commented -
nested comment blocks.  And I want it to uncomment
when I tell it to uncomment.  This particular DWIM
doesn't do-what-I-want.  (It may do-what-you-want.)

> > (defun comment-region-lines (beg end &optional arg)
> >   "Like `comment-region', but comment/uncomment
> >   whole lines." [...]
> 
> What do you mean by "whole lines"?

What the code says.  Regardless of the columns
of point and mark, their lines and the lines
between them are commented, from bol.

(let ((bol  (save-excursion 
              (goto-char beg) 
              (line-beginning-position)))
      (eol  (save-excursion 
              (goto-char end) 
              (if (bolp) (point) (line-end-position)))))
  (comment-region bol eol arg))



reply via email to

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