all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Antonin Houska <ah@cybertec.at>
To: npostavs@users.sourceforge.net
Cc: 26049@debbugs.gnu.org
Subject: bug#26049: 25.2; Extra lines not added to comment
Date: Tue, 28 Mar 2017 14:52:21 +0200	[thread overview]
Message-ID: <7171.1490705541@localhost> (raw)
In-Reply-To: <87r31i2i5a.fsf@users.sourceforge.net>

[-- Attachment #1: Type: text/plain, Size: 1836 bytes --]

npostavs@users.sourceforge.net wrote:

> Antonin Houska <ah@cybertec.at> writes:

> > Even though I have the following customizations in place
> >
> >  '(comment-multi-line t)
> >  '(comment-style (quote extra-line))
> >
> > comment-region command produces this
> >
> > /* some comment */
> >
> > rather than this
> >
> > /*
> >  * some comment
> >  */
> >
> > Attached is a patch that I use to fix the issue on my workstation. Besides
> > fixing the (supposed) off-by-one error, the patch also removes trailing
> > whitespace from the initial line of the comment ("/* "). (My knowledge of
> > Elisp is not too advanced so I wonder if there's simpler way to trim
> > whitespace from a string.)
> >

> You can use use `string-trim-right' from subr-x.

Thanks.

> >   	   (progn (goto-char end) (end-of-line) (skip-syntax-backward " ")
> >   		  (<= (point) end))
> >   	   (or block (not (string= "" comment-end)))
> > ! 	   (or block (progn (goto-char beg) (search-forward
> > !                                              "\n"
> > !                                              (min (1+ end) (point-max)) t)))))

> Maybe (re-search-forward "$" end t) is better?  It's a bit unclear to me
> what exactly all those tests are looking for.  That code could use some
> comments...

I've just verified your approach - it does work too.

Yes, comments would be useful. For the test we're fixing now, the reason seems
to be to ensure that the last line of the comment can be broken w/o affecting
the following (non-comment) text. Perhaps someone else might come up with
better wording.

New version of the patch is attached.

-- 
Antonin Houska
Cybertec Schönig & Schönig GmbH
Gröhrmühlgasse 26
A-2700 Wiener Neustadt
Web: http://www.postgresql-support.de, http://www.cybertec.at


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: newcomment_v2.diff --]
[-- Type: text/x-diff, Size: 1518 bytes --]

diff --git a/lisp/newcomment.el b/lisp/newcomment.el
new file mode 100644
index 1af8929..f2d9735
*** a/lisp/newcomment.el
--- b/lisp/newcomment.el
***************
*** 69,74 ****
--- 69,77 ----
  
  ;;; Code:
  
+ (eval-when-compile
+   (require 'subr-x))
+ 
  ;;;###autoload
  (defalias 'indent-for-comment 'comment-indent)
  ;;;###autoload
*************** the region rather than at left margin."
*** 1139,1144 ****
--- 1142,1150 ----
  
  	  ;; make the leading and trailing lines if requested
  	  (when lines
+ 	    ;; Trim trailing whitespace from cs if there's some.
+             (setq cs (string-trim cs))
+ 
  	    (let ((csce
  		   (comment-make-extra-lines
  		    cs ce ccs cce min-indent max-indent block)))
*************** changed with `comment-style'."
*** 1209,1215 ****
  	   (progn (goto-char end) (end-of-line) (skip-syntax-backward " ")
  		  (<= (point) end))
  	   (or block (not (string= "" comment-end)))
! 	   (or block (progn (goto-char beg) (search-forward "\n" end t)))))
  
      ;; don't add end-markers just because the user asked for `block'
      (unless (or lines (string= "" comment-end)) (setq block nil))
--- 1215,1221 ----
  	   (progn (goto-char end) (end-of-line) (skip-syntax-backward " ")
  		  (<= (point) end))
  	   (or block (not (string= "" comment-end)))
! 	   (or block (progn (goto-char beg) (re-search-forward "$" end t)))))
  
      ;; don't add end-markers just because the user asked for `block'
      (unless (or lines (string= "" comment-end)) (setq block nil))

  reply	other threads:[~2017-03-28 12:52 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-10 13:41 bug#26049: 25.2; Extra lines not added to comment Antonin Houska
2017-03-28  3:29 ` npostavs
2017-03-28 12:52   ` Antonin Houska [this message]
2017-03-29  2:25     ` npostavs
2017-03-29  6:54       ` Antonin Houska
2017-09-23  7:41         ` Antonin Houska
2017-09-23 14:37           ` Noam Postavsky
2017-11-06 10:14             ` Antonin Houska
2017-11-07  0:07               ` Noam Postavsky

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=7171.1490705541@localhost \
    --to=ah@cybertec.at \
    --cc=26049@debbugs.gnu.org \
    --cc=npostavs@users.sourceforge.net \
    /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.