[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#21072: Brave new mark-defun (and a testing tool)
From: |
John Mastro |
Subject: |
bug#21072: Brave new mark-defun (and a testing tool) |
Date: |
Tue, 18 Apr 2017 17:35:06 -0700 |
<npostavs@users.sourceforge.net> wrote:
> (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)))))
>
> 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.
Would it help to lean on (forward-comment -1) more?
Something like this:
(defun beginning-of-defun-comments (&optional arg)
(interactive "^p")
(let ((arg (or arg 1))
point)
(beginning-of-defun arg)
(setq point (point))
(while (not (eq point (setq point (progn (forward-comment -1) (point))))))
(skip-chars-forward "[:space:]\r\n")))
Having to `skip-chars-forward' at the end seems a bit awkward, but I
think it does work on the recently mentioned JavaScript examples.
John
John
- bug#21072: Brave new mark-defun (and a testing tool), Glenn Morris, 2017/04/02
- bug#21072: Brave new mark-defun (and a testing tool), Marcin Borkowski, 2017/04/21
- bug#21072: Brave new mark-defun (and a testing tool), Marcin Borkowski, 2017/04/21
- bug#21072: Brave new mark-defun (and a testing tool), npostavs, 2017/04/22
- bug#21072: Brave new mark-defun (and a testing tool), Marcin Borkowski, 2017/04/24
- bug#21072: Brave new mark-defun (and a testing tool), npostavs, 2017/04/24
- bug#21072: Brave new mark-defun (and a testing tool), Marcin Borkowski, 2017/04/25
- bug#21072: Brave new mark-defun (and a testing tool), npostavs, 2017/04/25
- bug#21072: Brave new mark-defun (and a testing tool), Noam Postavsky, 2017/04/25