all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Kevin Rodgers <ihs_4664@yahoo.com>
Subject: Re: How make comment-region NOT ignore blank lines but comment out those too?
Date: Thu, 28 Aug 2003 10:49:32 -0600	[thread overview]
Message-ID: <3F4E329C.1010401@yahoo.com> (raw)
In-Reply-To: bf23f78f.0308272337.7a81651c@posting.google.com

Christian Seberino wrote:

> Thanks.
> 
> Is it possible to do a search and replace automatically as a "hook" to
> comment-region????
> 
> The file will have this problem as "\n#  \n".
> I just have to replace that with "\n#\n".
> 
> I believe this is called a regular expression??
> 
> Can they be run every time we do a comment-region?

You can always try (this is completely untested):

(defadvice comment-region (after unpad-blank-line-comments)
   "If blank lines are commented, delete `comment-padding' on those lines."
   (if (and (null (ad-get-arg 2))	; (null ARG), (null current-prefix-arg)
	   comment-empty-lines)
       ;; We are commenting, not uncommenting.
       (let ((empty-comment-regexp (format "^[ \t]*\\(%s\\)\\(%s\\)$"
					  comment-start
					  comment-padding)))
	(save-restriction
	  (narrow-to-region (ad-get-arg 0) (ad-get-arg 1)) ; (... BEG END)
	  (goto-char (point-min))
	  (while (re-search-forward empty-comment-regexp nil t)
	    (replace-match "" nil nil nil 2))))))

-- 
Kevin Rodgers

      reply	other threads:[~2003-08-28 16:49 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-08-14 17:12 How make comment-region NOT ignore blank lines but comment out those too? Christian Seberino
2003-08-14 22:06 ` Jesper Harder
2003-08-15 20:39   ` Christian Seberino
2003-08-15 23:36     ` Jesper Harder
2003-08-26  0:04       ` Christian Seberino
2003-08-26  0:37       ` Christian Seberino
2003-08-26 14:04         ` Jesper Harder
2003-08-27 21:57           ` Christian Seberino
2003-08-28  1:38             ` Jesper Harder
2003-08-28  7:37               ` Christian Seberino
2003-08-28 16:49                 ` Kevin Rodgers [this message]

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=3F4E329C.1010401@yahoo.com \
    --to=ihs_4664@yahoo.com \
    /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.