]> git.eshelyaron.com Git - emacs.git/commitdiff
Modify `beginning-of-defun-comments'
authorNoam Postavsky <npostavs@gmail.com>
Tue, 9 May 2017 07:38:49 +0000 (09:38 +0200)
committerMarcin Borkowski <mbork@mbork.pl>
Fri, 12 May 2017 09:40:57 +0000 (11:40 +0200)
* lisp/emacs-lisp/lisp.el (beginning-of-defun-comments): Try not to stop
in the middle of a multiline comment.

lisp/emacs-lisp/lisp.el

index 71c27d08a2f3b59d98b2ae8fb75ca7fe495cf915..0c1fe42fedb12cc6887fccc42526f2000856044e 100644 (file)
@@ -417,14 +417,22 @@ whitespace."
   (interactive "^p")
   (unless arg (setq arg 1))
   (beginning-of-defun arg)
-  (let (nbobp)
-    (while (progn
-             (setq nbobp (zerop (forward-line -1)))
-             (and (not (looking-at "^\\s-*$"))
-                  (beginning-of-defun--in-emptyish-line-p)
-                  nbobp)))
-    (when nbobp
-      (forward-line 1))))
+  (let (first-line-p)
+    (while (let ((ppss (progn (setq first-line-p (= (forward-line -1) -1))
+                              (syntax-ppss (line-end-position)))))
+             (while (and (nth 4 ppss) ; If eol is in a line-spanning comment,
+                         (< (nth 8 ppss) (line-beginning-position)))
+               (goto-char (nth 8 ppss)) ; skip to comment start.
+               (setq ppss (syntax-ppss (line-end-position))))
+             (and (not first-line-p)
+                  (progn (skip-syntax-backward
+                          "-" (line-beginning-position))
+                         (not (bolp))) ; Check for blank line.
+                  (progn (parse-partial-sexp
+                          (line-beginning-position) (line-end-position)
+                          nil t (syntax-ppss (line-beginning-position)))
+                         (eolp))))) ; Check for non-comment text.
+    (forward-line (if first-line-p 0 1))))
 
 (defvar end-of-defun-function
   (lambda () (forward-sexp 1))