From: martin rudalics <rudalics@gmx.at>
Cc: bug-cc-mode@gnu.org, emacs-pretest-bug@gnu.org, emacs-devel@gnu.org
Subject: Re: Mysterious fontification/C++ context issue
Date: Wed, 06 Dec 2006 10:04:23 +0100 [thread overview]
Message-ID: <45768797.5010106@gmx.at> (raw)
In-Reply-To: <20061204203024.D17603@colin2.muc.de>
[-- Attachment #1: Type: text/plain, Size: 1409 bytes --]
> Here's a tentative fix for the bug, not that well tested, but tested a
> little bit:
>
> 2006-12-04 Alan Mackenzie <acm@muc.de>
>
> * emacs-lisp/lisp.el (beginning-of-defun-raw): In the seeking a
> non-nested open-paren case, check there are enough lists to move
> over. Return the correct value.
Thanks for taking care of this. Please note:
1. You don't widen the buffer before calling `syntax-ppss'.
2. A construct built along
(foo
) (bar)
with point at "bar" might derail font-lock (remember,
`c-beginning-of-defun-1' calls `beginning-of-defun', not
`beginning-of-defun-raw').
3. All this is still awfully slow and expensive: Open a larger buffer
like xdisp.c, jump to its end, hit M-v a couple of times, and look at
CPU consumption.
4. You could avoid the tedious `up-list' steps by using a variant of the
tentative fix I attached.
5. Consider making `open-paren-in-column-0-is-defun-start' a real user
option in C mode. Let, for example, users decide whether they want to
respect GNU coding standards as mentioned in
http://lists.gnu.org/archive/html/bug-gnu-emacs/2006-11/msg00037.html
This should also permit binding C-M-a / C-M-e to `c-beginning-of-defun'
/ `c-end-of-defun' when `open-paren-in-column-0-is-defun-start' is nil.
6. In any case, the new behavior should be documented since it applies
whenever `open-paren-in-column-0-is-defun-start' is set to nil.
[-- Attachment #2: lisp.patch --]
[-- Type: text/plain, Size: 2375 bytes --]
*** lisp.el Thu Nov 9 07:55:26 2006
--- lisp.el Wed Dec 6 08:53:18 2006
***************
*** 229,271 ****
"^\\s(")
nil 'move arg)
(progn (goto-char (1- (match-end 0)))) t))
-
(t
! ;; Column 0 has no significance - so scan forward from BOB to see how
! ;; nested point is, then carry on from there.
! (let* ((floor (point-min))
! (ceiling (point-max))
! (pps-state (let (syntax-begin-function
! font-lock-beginning-of-syntax-function)
! (syntax-ppss)))
! (nesting-depth (nth 0 pps-state)))
(save-restriction
(widen)
! ;; Get outside of any string or comment.
! (if (nth 8 pps-state)
! (goto-char (nth 8 pps-state)))
!
! (cond
! ((> arg 0)
! (when (> nesting-depth 0)
! (up-list (- nesting-depth))
! (setq arg (1- arg)))
! ;; We're now outside of any defun.
! (backward-list arg)
! (if (< (point) floor) (goto-char floor)))
!
! ((< arg 0)
! (cond
! ((> nesting-depth 0)
! (up-list nesting-depth)
! (setq arg (1+ arg)))
! ((not (looking-at "\\s("))
! ;; We're between defuns, and not at the start of one.
! (setq arg (1+ arg))))
! (forward-list (- arg))
! (down-list)
! (backward-char)
! (if (> (point) ceiling) (goto-char ceiling)))))))))
(defvar end-of-defun-function nil
"If non-nil, function for function `end-of-defun' to call.
--- 229,263 ----
"^\\s(")
nil 'move arg)
(progn (goto-char (1- (match-end 0)))) t))
(t
! (let ((floor (point-min))
! (ceiling (point-max)))
(save-restriction
(widen)
! (let* ((ppss (let (syntax-begin-function
! font-lock-beginning-of-syntax-function)
! (syntax-ppss)))
! (pos (or (let ((pos (car (nth 9 ppss))))
! (when pos ; Within defun.
! (when (> arg 0) (setq arg (1- arg)))
! pos))
! (nth 8 ppss) ; Within string or comment.
! (point)))) ; Must be at outermost level.
! (goto-char pos)
! (condition-case nil
! (progn
! (forward-list (- arg))
! (cond
! ((< pos floor)
! (goto-char floor)
! nil)
! ((> pos ceiling)
! (goto-char ceiling)
! nil)
! (t)))
! (error
! (goto-char (if (< arg 0) ceiling floor))
! nil))))))))
(defvar end-of-defun-function nil
"If non-nil, function for function `end-of-defun' to call.
[-- Attachment #3: Type: text/plain, Size: 161 bytes --]
_______________________________________________
emacs-pretest-bug mailing list
emacs-pretest-bug@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-pretest-bug
next prev parent reply other threads:[~2006-12-06 9:04 UTC|newest]
Thread overview: 110+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <87y7po2e9b.fsf@leeloo.anubex.internal>
[not found] ` <45741FBE.3000107@swipnet.se>
[not found] ` <45742464.1090504@gmx.at>
2006-12-04 21:17 ` Mysterious fontification/C++ context issue Alan Mackenzie
2006-12-06 0:47 ` Richard Stallman
2006-12-06 9:04 ` martin rudalics [this message]
2006-12-06 12:22 ` Kim F. Storm
2006-12-06 16:31 ` Chong Yidong
2006-12-07 4:59 ` Richard Stallman
2006-12-09 17:46 ` Chong Yidong
2006-12-09 20:09 ` Stefan Monnier
2006-12-11 1:05 ` Richard Stallman
2006-12-11 2:27 ` Stefan Monnier
2006-12-11 4:38 ` Stefan Monnier
2006-12-12 16:24 ` Chong Yidong
2006-12-12 17:10 ` Stefan Monnier
2006-12-10 4:24 ` Richard Stallman
2006-12-10 0:35 ` Alan Mackenzie
2006-12-10 1:11 ` Chong Yidong
2006-12-10 9:12 ` Alan Mackenzie
2006-12-10 12:46 ` David Kastrup
2006-12-10 14:50 ` Alan Mackenzie
2006-12-10 15:13 ` David Kastrup
2006-12-10 20:30 ` Chong Yidong
2006-12-13 21:29 ` Mysterious fontification/C++ context issue - Patch for beginning-of-defun-raw Alan Mackenzie
2006-12-14 1:02 ` Chong Yidong
2006-12-14 7:36 ` Alan Mackenzie
2006-12-14 10:47 ` martin rudalics
2006-12-14 18:26 ` Alan Mackenzie
2006-12-14 18:53 ` David Kastrup
2006-12-14 20:21 ` Chong Yidong
2006-12-14 20:35 ` Chong Yidong
2006-12-14 22:18 ` Alan Mackenzie
2006-12-14 22:51 ` Chong Yidong
2006-12-15 0:53 ` David Kastrup
2006-12-15 10:35 ` Johan Bockgård
2006-12-14 21:53 ` What `opic0ids' really is [was: Mysterious fontification/C++ context issue - Patch for beginning-of-defun-raw.] Stuart D. Herring
2006-12-15 7:32 ` Mysterious fontification/C++ context issue - Patch for beginning-of-defun-raw martin rudalics
2006-12-15 19:22 ` Alan Mackenzie
2006-12-15 22:20 ` David Kastrup
2006-12-16 10:17 ` martin rudalics
2006-12-17 11:44 ` Alan Mackenzie
2006-12-17 12:02 ` David Kastrup
2006-12-17 12:08 ` Alan Mackenzie
2006-12-17 12:14 ` David Kastrup
2006-12-17 12:26 ` Alan Mackenzie
2006-12-17 12:51 ` David Kastrup
2006-12-17 17:28 ` martin rudalics
2006-12-17 18:36 ` Mysterious fontification/C++ context issue - Patch for c-basic-common-init Alan Mackenzie
2006-12-17 18:45 ` Chong Yidong
2006-12-17 22:18 ` Alan Mackenzie
2006-12-17 22:59 ` Chong Yidong
2006-12-18 0:06 ` Mysterious fontification/C++ context issue - Patch for beginning-of-defun-raw Stefan Monnier
2006-12-15 23:24 ` Stefan Monnier
2006-12-16 10:17 ` martin rudalics
2006-12-16 18:14 ` Chong Yidong
2006-12-16 18:27 ` martin rudalics
2006-12-16 19:00 ` martin rudalics
2006-12-16 19:33 ` Chong Yidong
2006-12-16 19:59 ` martin rudalics
2006-12-16 20:10 ` Chong Yidong
2006-12-16 21:26 ` Chong Yidong
2006-12-16 22:43 ` martin rudalics
2006-12-16 23:30 ` Stefan Monnier
2006-12-16 23:40 ` martin rudalics
2006-12-17 0:04 ` Stefan Monnier
2006-12-17 4:02 ` Chong Yidong
2006-12-17 10:32 ` martin rudalics
2006-12-17 10:26 ` martin rudalics
2006-12-17 10:59 ` David Kastrup
2006-12-17 23:23 ` Stefan Monnier
2006-12-17 11:10 ` Alan Mackenzie
2006-12-17 12:01 ` David Kastrup
2006-12-18 0:04 ` Stefan Monnier
2006-12-16 22:11 ` martin rudalics
2006-12-16 23:29 ` Stefan Monnier
2006-12-16 23:37 ` martin rudalics
2006-12-16 20:22 ` David Kastrup
2006-12-16 22:21 ` martin rudalics
2006-12-14 17:29 ` Chong Yidong
2006-12-14 18:56 ` David Kastrup
2006-12-14 22:57 ` Alan Mackenzie
2006-12-15 22:56 ` Stefan Monnier
2006-12-15 23:03 ` David Kastrup
2006-12-14 10:45 ` martin rudalics
2006-12-14 18:29 ` Alan Mackenzie
2006-12-15 22:49 ` Stefan Monnier
2006-12-10 21:39 ` Mysterious fontification/C++ context issue Stefan Monnier
2006-12-10 23:14 ` Kim F. Storm
2006-12-14 7:43 ` Alan Mackenzie
2006-12-14 7:51 ` Miles Bader
2006-12-15 23:36 ` Stefan Monnier
2006-12-10 9:18 ` martin rudalics
2006-12-11 1:23 ` Stefan Monnier
2006-12-11 7:23 ` martin rudalics
2006-12-11 7:36 ` Stefan Monnier
2006-12-11 8:32 ` martin rudalics
2006-12-11 16:30 ` Stefan Monnier
2006-12-11 1:05 ` Stefan Monnier
2006-12-11 1:06 ` Richard Stallman
2006-12-06 18:44 ` Richard Stallman
2006-12-06 22:38 ` martin rudalics
2006-12-08 5:05 ` Richard Stallman
2006-12-09 9:42 ` martin rudalics
2006-12-10 4:24 ` Richard Stallman
2006-12-10 8:38 ` martin rudalics
2006-12-10 10:56 ` Alan Mackenzie
2006-12-10 11:58 ` martin rudalics
2006-12-10 14:30 ` Slawomir Nowaczyk
2006-12-11 1:29 ` Stefan Monnier
2006-12-06 20:52 ` Alan Mackenzie
2006-12-06 22:38 ` martin rudalics
2006-12-07 5:07 ` Stefan Monnier
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=45768797.5010106@gmx.at \
--to=rudalics@gmx.at \
--cc=bug-cc-mode@gnu.org \
--cc=emacs-devel@gnu.org \
--cc=emacs-pretest-bug@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).