emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Arthur Miller <arthur.miller@live.com>
To: John Kitchin <jkitchin@andrew.cmu.edu>
Cc: Tim Cross <theophilusx@gmail.com>,
	Org-mode <emacs-orgmode@gnu.org>,
	Emacs developers <emacs-devel@gnu.org>
Subject: Re: Font lock in org+elisp confused with ?\[
Date: Sat, 03 Apr 2021 20:38:28 +0200	[thread overview]
Message-ID: <AM9PR09MB4977666239832DD7EF1F832696799@AM9PR09MB4977.eurprd09.prod.outlook.com> (raw)
In-Reply-To: <CAJ51ETpah5QXNBTZW8tU246r639RdKERJisV4Z4t1GiPH9b3MA@mail.gmail.com> (John Kitchin's message of "Fri, 2 Apr 2021 09:03:53 -0400")

John Kitchin <jkitchin@andrew.cmu.edu> writes:

> This is related to the issues with <> in src blocks. [ and ] have open and close syntactical meanings like < and > do in org files. A similar solution as found in
> https://emacs.stackexchange.com/questions/50216/org-mode-code-block-parentheses-mismatch seems to work to fix it.

Indeed, the code from SX works, I took the simpler version and converted
it to work with square brackets:

#+begin_src emacs-lisp
             (defun org-mode-sqbr-syntax-fix (start end)
               (when (eq major-mode 'org-mode)
                   (goto-char start)
                   (while (re-search-forward "[]\\[]" end t)
                     (when (get-text-property (point) 'src-block)
                       ;; This is a ?[ or ?] in an org-src block
                       (put-text-property (point) (1- (point))
                                          'syntax-table (string-to-syntax "_")))))))

             (defun org-setup-sqbr-syntax-fix ()
               "Setup for characters ?[ and ?] in source code blocks.
  Add this function to `org-mode-hook'."
               (setq syntax-propertize-function 'org-mode-sqbr-syntax-fix)
               (syntax-propertize (point-max)))

             (add-hook 'org-mode-hook 'org-setup-sqbr-syntax-fix)

I have confirmed that code runs when I load my org file, but there seems
to be something else than that callback involed, later on, evaluating
and changing those properties back. I still see same error in the
babel-block. However when I run fix explicitly on that code block (I
converted it to interactive "r" for test), then syntax is fine. So it
seems there is some other callback involved.

Sorry little bit late answer, I thought I sent this a day ago or so, but
apparently I didn't.

Thanks for the help.

      parent reply	other threads:[~2021-04-03 18:39 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <AM9PR09MB497740C52C6EE5A5680C9D84967B9@AM9PR09MB4977.eurprd09.prod.outlook.com>
2021-04-02  4:23 ` Font lock in org+elisp confused with ?\[ Tim Cross
2021-04-02 13:03   ` John Kitchin
2021-04-02 22:59     ` Tom Gillespie
2021-04-03 18:38     ` Arthur Miller [this message]

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:

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=AM9PR09MB4977666239832DD7EF1F832696799@AM9PR09MB4977.eurprd09.prod.outlook.com \
    --to=arthur.miller@live.com \
    --cc=emacs-devel@gnu.org \
    --cc=emacs-orgmode@gnu.org \
    --cc=jkitchin@andrew.cmu.edu \
    --cc=theophilusx@gmail.com \


* 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


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).