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

From: [email-masked]
Date: Mon, 24 Apr 2017 08:52:10 -0400

Marcin Borkowski <[email-masked]> writes:

> On 2017-04-22, at 20:05, [email-masked] wrote:
>
>>> 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...
>>
>> Hmm, I don't get that, although I did miss an inf loop when the comment
>> is at beginning of buffer.  Here is a fixed version:
>
> Still the same here, also in emacs -Q.

Hmm, I was testing before now just by evaluating the changed functions
after startup, I must have messed something up.  I think this one might
be okay.

    (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 (line-beginning-position))
                   (ppss (and (zerop (forward-line -1)) (syntax-ppss))))
               (cond ((nth 4 ppss) (goto-char (nth 8 ppss)))
                     ((and ppss
                           (parse-partial-sexp
                            (point) (line-end-position) nil t ppss)
                           (not (bolp)) (eolp)))
                     (t (goto-char pt) nil)))))

>>
>> Looks good to me (apart from the commit messages).

Actually, now that I've applied this thing properly, I notice 2 test
failures in batch mode:

2 unexpected results:
   FAILED  mark-defun-arg-region-active
   FAILED  mark-defun-no-arg-region-active

They pass when run in interactive mode (I haven't looked into why).

>
> What should they look like, then?  Should I make all of them into the
> ChangeLog format, or just rebase/squash all of them so that there are
> two of them only (one for the testing tool and one for the
> beginning-of-defun)?

Yeah, I would go ahead and squash them, since you need to rebase to fix
commit messages anyway.