emacs-devel
[Top][All Lists]
Advanced

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

Re: Several Major Modes.


From: Dmitry Gutov
Subject: Re: Several Major Modes.
Date: Sun, 17 Nov 2019 23:56:16 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0

On 17.11.2019 18:03, Alan Mackenzie wrote:
Hello, Dmitry.

On Sun, Nov 17, 2019 at 14:48:35 +0200, Dmitry Gutov wrote:
Hi Alan,

On 16.11.2019 15:10, Alan Mackenzie wrote:

You also need to make sure narrowing is available for any purpose
required by a major mode.

Eh, I think it's "available" already, but I'd have to see specific
examples.

Oh good!  I have to admit I haven't actually seen MMM Mode running,
or at least I don't remember it.

I think we won't really know until there's a good change of CC Mode
working with MMM Mode, so then people could try and exercise various
features. And we'll see what works and what does not.

Other than CC Mode's handling of syntax-table text properties, what
precisely is hindering it working in MMM Mode?  (That question's partly
addressed at myself.)

[ .... ]

Here's the email you missed. For some reason I can't find it in the emacs-devel archive, but it was also addressed to you and Stefan, and Stefan received it:

(quote begins)

By the way, I had a thought.

Like, normally font-lock does widen the buffer before fontifying anything. So I was wondering, why doesn't this happen between steps iii and iv somewhere?

Turns out, the (unless font-lock-dont-widen (widen)) calls are performed inside the default values of font-lock-fontify-region-function and font-lock-fontify-buffer-function.

But CC Mode sets font-lock-fontify-region-function to a different value, and that specific function doesn't include this piece of code. Or rather, didn't. The new commit added an unconditional (widen) call.

I think if you simply wrap it in (unless font-lock-dont-widen ...), it will improve compatibility with mmm-mode already (without adverse effects, I imagine). After that, you could audit if the other (widen) calls spread across CC Mode are still necessary. Maybe they're used in indentation code (that's also solvable). Maybe also by some other commands.

(quote ends)

This would be the first step. It really comes down to my original request:

diff --git a/lisp/progmodes/cc-mode.el b/lisp/progmodes/cc-mode.el
index 73160fc7a4..9b27ee79e9 100644
--- a/lisp/progmodes/cc-mode.el
+++ b/lisp/progmodes/cc-mode.el
@@ -2233,7 +2233,7 @@ c-font-lock-fontify-region
;; Type a space in the first blank line, and the fontification of the next
   ;; line was fouled up by context fontification.
   (save-restriction
-    (widen)
+    (unless font-lock-dont-widen (widen))
     (let (new-beg new-end new-region case-fold-search)
       (if (and c-in-after-change-fontification
               (< beg c-new-END) (> end c-new-BEG))



reply via email to

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