emacs-devel
[Top][All Lists]
Advanced

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

Re: beginning-of-defun-comments bug [was: Re: 26.0.90: mark-defun proble


From: zhang cc
Subject: Re: beginning-of-defun-comments bug [was: Re: 26.0.90: mark-defun problem in c-mode]
Date: Fri, 5 Jan 2018 14:55:54 +0000


On 4 Jan 2018, 12:28 AM +0800, Alan Mackenzie <address@hidden>, wrote:

Sorry, I got distracted by the turn of the year, and one or two other
things. Please try this:



diff --git a/lisp/emacs-lisp/lisp.el b/lisp/emacs-lisp/lisp.el
index 6952ef4cf4..28605cd35c 100644
--- a/lisp/emacs-lisp/lisp.el
+++ b/lisp/emacs-lisp/lisp.el
@@ -405,12 +405,13 @@ beginning-of-defun--in-emptyish-line-p
;; See https://lists.gnu.org/r/help-gnu-emacs/2016-08/msg00141.html
(save-excursion
(forward-line 0)
- (< (line-end-position)
- (let ((ppss (syntax-ppss)))
- (when (nth 4 ppss)
- (goto-char (nth 8 ppss)))
- (forward-comment (point-max))
- (point)))))
+ (let ((ppss (syntax-ppss)))
+ (and (null (nth 3 ppss))
+ (< (line-end-position)
+ (progn (when (nth 4 ppss)
+ (goto-char (nth 8 ppss)))
+ (forward-comment (point-max))
+ (point)))))))

(defun beginning-of-defun-comments (&optional arg)
"Move to the beginning of ARGth defun, including comments."
@@ -428,10 +429,7 @@ beginning-of-defun-comments
(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.
+ (beginning-of-defun--in-emptyish-line-p)))) ; Check for non-comment text.
(forward-line (if first-line-p 0 1))))

(defvar end-of-defun-function


Best,

--
Marcin Borkowski

--
Alan Mackenzie (Nuremberg, Germany). 


I applied the patch, and I can’t reproduce the problem now. But there is something I don’t known if it is intended.

With the following c code, run mark-defun with cursor in the body of the second function, and the comment above of the function is also marked.

int test_func1(int a)
{
int i;

return 0;
}
/*
 * aa
 */
int test_func2(int a)
{
int i;

return 0;
}


reply via email to

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