From: martin rudalics <rudalics@gmx.at>
To: William Xue <william.xue@gmail.com>
Cc: emacs-devel@gnu.org
Subject: Re: How to use c-style to comment a region?
Date: Thu, 10 May 2007 10:50:20 +0200 [thread overview]
Message-ID: <4642DCCC.2020003@gmx.at> (raw)
In-Reply-To: <op.tr1viwlvhkv0w5@williamnb>
[-- Attachment #1: Type: text/plain, Size: 473 bytes --]
> That's not my request, I only want a command or a keybinding.
You could try to bind
(defun my-cpp-comment-region (beg end &optional arg)
(interactive "*r\nP")
(let ((comment-start "/* ")
(comment-end " */"))
(comment-region beg end arg)))
to a key.
BTW with comment-styles box / box-multi and newline terminated comment
syntax `comment-region' comments out the entire text from the beginning
of the region till EOL. The attached patch should cure that.
[-- Attachment #2: new-comment.patch --]
[-- Type: text/plain, Size: 3162 bytes --]
*** newcomment.el.~1.101.~ Mon Apr 2 07:45:08 2007
--- newcomment.el Thu May 10 10:38:22 2007
***************
*** 926,941 ****
the region rather than at left margin."
;;(assert (< beg end))
(let ((no-empty (not (or (eq comment-empty-lines t)
! (and comment-empty-lines (zerop (length ce)))))))
;; Sanitize CE and CCE.
(if (and (stringp ce) (string= "" ce)) (setq ce nil))
(if (and (stringp cce) (string= "" cce)) (setq cce nil))
;; If CE is empty, multiline cannot be used.
(unless ce (setq ccs nil cce nil))
;; Should we mark empty lines as well ?
(if (or ccs block lines) (setq no-empty nil))
;; Make sure we have end-markers for BLOCK mode.
! (when block (unless ce (setq ce (comment-string-reverse cs))))
;; If BLOCK is not requested, we don't need CCE.
(unless block (setq cce nil))
;; Continuation defaults to the same as CS and CE.
--- 926,943 ----
the region rather than at left margin."
;;(assert (< beg end))
(let ((no-empty (not (or (eq comment-empty-lines t)
! (and comment-empty-lines (zerop (length ce))))))
! ce-sanitized)
;; Sanitize CE and CCE.
(if (and (stringp ce) (string= "" ce)) (setq ce nil))
+ (setq ce-sanitized ce)
(if (and (stringp cce) (string= "" cce)) (setq cce nil))
;; If CE is empty, multiline cannot be used.
(unless ce (setq ccs nil cce nil))
;; Should we mark empty lines as well ?
(if (or ccs block lines) (setq no-empty nil))
;; Make sure we have end-markers for BLOCK mode.
! (when (and block (not ce)) (setq ce (comment-string-reverse cs)))
;; If BLOCK is not requested, we don't need CCE.
(unless block (setq cce nil))
;; Continuation defaults to the same as CS and CE.
***************
*** 945,951 ****
(goto-char end)
;; If the end is not at the end of a line and the comment-end
;; is implicit (i.e. a newline), explicitly insert a newline.
! (unless (or ce (eolp)) (insert "\n") (indent-according-to-mode))
(comment-with-narrowing beg end
(let ((min-indent (point-max))
(max-indent 0))
--- 947,954 ----
(goto-char end)
;; If the end is not at the end of a line and the comment-end
;; is implicit (i.e. a newline), explicitly insert a newline.
! (unless (or ce-sanitized (eolp))
! (insert "\n") (indent-according-to-mode))
(comment-with-narrowing beg end
(let ((min-indent (point-max))
(max-indent 0))
***************
*** 1163,1169 ****
(buffer-substring (point)
(progn (move-to-left-margin)
(point)))))))))))))
!
;;;###autoload
(defun comment-indent-new-line (&optional soft)
--- 1166,1172 ----
(buffer-substring (point)
(progn (move-to-left-margin)
(point)))))))))))))
!
;;;###autoload
(defun comment-indent-new-line (&optional soft)
[-- Attachment #3: Type: text/plain, Size: 142 bytes --]
_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel
next prev parent reply other threads:[~2007-05-10 8:50 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-05-10 1:46 How to use c-style to comment a region? William Xue
2007-05-10 8:50 ` martin rudalics [this message]
2007-05-10 17:22 ` Stefan Monnier
2007-05-10 21:40 ` martin rudalics
2007-05-11 2:04 ` William Xue
2007-05-10 21:14 ` Alan Mackenzie
2007-05-11 2:10 ` William Xue
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=4642DCCC.2020003@gmx.at \
--to=rudalics@gmx.at \
--cc=emacs-devel@gnu.org \
--cc=william.xue@gmail.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.