unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: fatiparty--- via Users list for the GNU Emacs text editor <help-gnu-emacs@gnu.org>
To: Fatiparty <fatiparty@tutanota.com>
Cc: Help Gnu Emacs <help-gnu-emacs@gnu.org>
Subject: rainbow-delimiters-mode, syntax-begin-function and font-lock-beginning-of-syntax-function
Date: Mon, 24 Jan 2022 10:55:47 +0100 (CET)	[thread overview]
Message-ID: <MuAVpNi--3-2@tutanota.com> (raw)
In-Reply-To: <Mu4wPqh--3-2@tutanota.com-Mu4wX4B----2>

Jan 23, 2022, 19:58 by help-gnu-emacs@gnu.org:

Would sections [1] and [2] still be relevant in this code? 

It includes the claim  of not using `syntax-begin-function' and
that `font-lock-beginning-of-syntax-function' could be obsolete.

Have looked for `font-lock-beginning-of-syntax-function' but
could not find information of possible obsolescence.
(define-minor-mode rainbow-delimiters-minor-mode
  "Colour Brace Marks according to their depth."
  nil
  ""   ; exclude modeline indicator
  nil 
  
  (font-lock-remove-keywords nil my-font-lock)

  (when rainbow-delimiters-minor-mode
    (font-lock-add-keywords nil rainbow-delimiters-font-lock 'append)
    (set (make-local-variable 'jit-lock-contextually) t)

    ;; flush-cache to avoid old values when modifying `syntax-begin-function'
    (when (or (bound-and-true-p syntax-begin-function)
              (bound-and-true-p font-lock-beginning-of-syntax-function))
      (syntax-ppss-flush-cache 0))

    ;; [1] Don't use `syntax-begin-function', as it may break the
    ;; assumption that `syntax-ppss' is equivalent to
    ;; `parse-partial-sexp' from `point-min'.

    (when (boundp 'syntax-begin-function)
      (set (make-local-variable 'syntax-begin-function) nil))

    ;; [2] Obsolete equivalent of `syntax-begin-function'.
    (when (boundp 'font-lock-beginning-of-syntax-function)
      (set (make-local-variable
            'font-lock-beginning-of-syntax-function) nil)) )

  (when font-lock-mode
    (if (fboundp 'font-lock-flush)
        (font-lock-flush)
      (with-no-warnings (font-lock-fontify-buffer)))))







  parent reply	other threads:[~2022-01-24  9:55 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-23  7:58 rainbow-delimiters-mode and syntax-begin-function fatiparty--- via Users list for the GNU Emacs text editor
     [not found] ` <Mu4wPqh--3-2@tutanota.com-Mu4wX4B----2>
2022-01-24  9:55   ` fatiparty--- via Users list for the GNU Emacs text editor [this message]
2022-01-24 23:18     ` rainbow-delimiters-mode, syntax-begin-function and font-lock-beginning-of-syntax-function Stefan Monnier via Users list for the GNU Emacs text editor
2022-01-25  8:46       ` fatiparty--- via Users list for the GNU Emacs text editor
2022-01-25 13:04         ` Stefan Monnier
2022-01-25 13:37           ` fatiparty--- via Users list for the GNU Emacs text editor
2022-01-25 13:55             ` Stefan Monnier
2022-01-25 15:05               ` fatiparty--- via Users list for the GNU Emacs text editor
2022-01-25 15:12               ` fatiparty--- via Users list for the GNU Emacs text editor

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=MuAVpNi--3-2@tutanota.com \
    --to=help-gnu-emacs@gnu.org \
    --cc=fatiparty@tutanota.com \
    /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.
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).