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: John Mastro
Subject: bug#21072: Brave new mark-defun (and a testing tool)
Date: Wed, 19 Apr 2017 17:47:46 -0700

John Mastro <address@hidden> wrote:
> 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.

I realized that `forward-comment' returns nil when something besides a
comment or whitespace was found, so my idea boils down to:

(defun beginning-of-defun-comments (&optional arg)
  (interactive "^p")
  (beginning-of-defun (or arg 1))
  (while (forward-comment -1))
  (skip-chars-forward "[:space:]\r\n"))





reply via email to

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