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

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

bug#21072: Brave new mark-defun (and a testing tool)


From: Marcin Borkowski
Subject: bug#21072: Brave new mark-defun (and a testing tool)
Date: Fri, 21 Apr 2017 14:24:34 +0200
User-agent: mu4e 0.9.19; emacs 26.0.50

On 2017-04-19, at 02:04, npostavs@users.sourceforge.net wrote:

> Marcin Borkowski <mbork@mbork.pl> writes:
>
>>> Oh, right, I thought it was doing backward-comment, but the difference
>>> is that it stops at blank lines, thus the *non-redundant* looking-at
>>> call.
>>>
>>> I wonder if that's a sensible thing to do for languages that have
>>> multiline comments though, e.g. Javascript:
>>>
>>> /*
>>>
>>> This function returns 0
>>>
>>> */
>>> function foo () {
>>>     return 0;
>>> }
>>>
>>> Although we might say that such comments should have "*" on the empty lines.
>>
>> Definitely.  OTOH, what if they don't...?  I'm not sure how to detect
>> such a situation.  Any ideas?
>
>     (defun beginning-of-defun-comments (&optional arg)
>       "Move to the beginning of ARGth defun, including comments."
>       (interactive "^p")
>       (unless arg (setq arg 1))
>       (beginning-of-defun arg)
>       (while (let ((pt (prog1 (point) (forward-line -1)))
>                    (ppss (syntax-ppss)))
>                (cond ((nth 4 ppss) (goto-char (nth 8 ppss)))
>                      ((and (parse-partial-sexp
>                             (point) (line-end-position) nil t ppss)
>                            (not (bolp)) (eolp)))
>                      (t (goto-char pt) nil)))))

Still not there - I tried first on Elisp, like this:

;; A comment
(defun ...)

and it left the point at the end of the "A comment" line instead of at
the beginning...

> However there will always be some comment style that doesn't work, e.g.
>
>     // Some description followed by a blank.
>
>     function name(arg) {
>
>     }
>
> Another option is to give up the comment marking, it seems a bit
> complicated to implement and explain to users.

I'm tempted to leave it is it is in my branch.  For one, I'm a bit tired
by all this and I'd like to move on; also, as you said above, there is
little hope to do it "100% correctly", and I guess my solution may be
good enough.  (I'm pretty sure it's better than the status quo, at
least.)

I wouldn't like to resign from marking comments; I think it is pretty
useful.

So I'm going to delete the branch with the wrong name and push another
one, with the fixes we discussed earlier.

Best,

--
Marcin Borkowski





reply via email to

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