bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#20761: 25.0.50.1, beginning-of-defun matches inside string


From: Andreas Röhler
Subject: bug#20761: 25.0.50.1, beginning-of-defun matches inside string
Date: Mon, 08 Jun 2015 11:09:35 +0200
User-agent: Mozilla/5.0 (X11; Linux i686; rv:31.0) Gecko/20100101 Thunderbird/31.4.0


Am 07.06.2015 um 19:21 schrieb Andreas Röhler:
emacs -Q

With cursor at end of string below:

(defun asdf ()
  "
(defun foo1 (&optional beg end)
  sdsd"
)

;;;

C-M-a stops  inside string at "(defun foo1"

GNU Emacs 25.0.50.1 (i686-pc-linux-gnu, GTK+ Version 2.24.23) of 2015-06-07

Solution:

beginning-of-defun-raw must check if being inside string.




This should fix it:

(defun ar-beginning-of-defun (&optional arg)
  "Move to the beginning of a function definition.

Returns position, if successful, nil otherwise

Calls `beginning-of-defun-function', when set "
  (interactive "P")
  (unless (bobp)
    (skip-chars-backward " \t\r\n\f")
    (forward-char -1)
(let ((pos (car-safe (nth 9 (parse-partial-sexp (point-min) (point))))))
      (if beginning-of-defun-function
      (funcall beginning-of-defun-function arg)
    (and pos
         (goto-char pos))))))

Optional arg here is for special needs, switches between class and method defs for example.






reply via email to

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