emacs-devel
[Top][All Lists]
Advanced

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

Re: sub and superscripts: without «_» and «^»


From: Tassilo Horn
Subject: Re: sub and superscripts: without «_» and «^»
Date: Thu, 03 Sep 2015 09:02:50 +0200
User-agent: Gnus/5.130014 (Ma Gnus v0.14) Emacs/25.0.50 (gnu/linux)

Stefan Monnier <address@hidden> writes:

>> I asked this on auctex-dev but it might be question concerning core
>> functionality of GNU emacs:
>
> The necessary core functionality has been present for a long time:
> just add the proper `invisible' property to the chars you don't want
> to see.

I guess what Uwe wants is that `prettify-symbols-mode' in a (La)TeX
buffer (with stock latex-mode or AUCTeX; doesn't really matter) could
have the option to make the ^ and _ invisible, too.

I already told him that this is not what p-s-m is meant for.  But it's
easy enough to write a custom font-lock rule for that:

--8<---------------cut here---------------start------------->8---
(defun th/invisible-super-sub-scripts ()
  (interactive)
  (cl-pushnew 'invisible font-lock-extra-managed-props)
  (font-lock-add-keywords
   nil
   '(("[^\\\\]\\([_^]\\)" (1 '(face nil invisible t) t))))
  (font-lock-flush))
--8<---------------cut here---------------end--------------->8---

Uwe, if you want you could do something like that:

--8<---------------cut here---------------start------------->8---
(add-hook 'prettify-symbols-mode-hook
          (lambda ()
            (when (eq major-mode 'latex-mode)
              (th/invisible-super-sub-scripts))))
--8<---------------cut here---------------end--------------->8---

Bye,
Tassilo



reply via email to

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