Subject: 11.90.0; [PATCH] Fontification of ``this", and interaction with 'composition

From: Ilya Zakharevich <[email-masked]>
Date: Mon, 14 Aug 2017 17:10:21 -0700

a) The highlighting of ``this" is wrong (does not stop at the
   finishing quote).
b) Handling of super/subscripts is not compatible with 'composition;
   e.g., with
         latex-pretty-symbols.el
   or https://stackoverflow.com/questions/22937393/emacs-lisp-prettify-symbols-mode-for-latex?rq=1

The patch is appended.

Enjoy,
Ilya

Emacs  : GNU Emacs 25.1.1 (i686-w64-mingw32)
 of 2016-09-17
Package: 11.90.0

current state:
==============
(setq
 AUCTeX-date "2017-01-11"
 window-system 'w32
 LaTeX-version "2e"
 TeX-style-path '("~/.emacs.d/auctex"
		  "c:/Users/Vera/AppData/Roaming/.emacs.d/elpa/auctex-11.90.0/style" "c:/Users/Vera/AppData/Roaming/.emacs.d/auctex/auto" "c:/Users/Vera/AppData/Roaming/.emacs.d/auctex/style" "auto" "style")
 TeX-auto-save nil
 TeX-parse-self nil
 TeX-master t
 TeX-command-list '(("TeX"
		     "%(PDF)%(tex) %(file-line-error) %(extraopts) %`%S%(PDFout)%(mode)%' %t"
		     TeX-run-TeX nil
		     (plain-tex-mode ams-tex-mode texinfo-mode) :help
		     "Run plain TeX")
		    ("LaTeX" "%`%l%(mode)%' %t" TeX-run-TeX nil
		     (latex-mode doctex-mode) :help "Run LaTeX")
		    ("Makeinfo" "makeinfo %(extraopts) %t" TeX-run-compile nil
		     (texinfo-mode) :help "Run Makeinfo with Info output")
		    ("Makeinfo HTML" "makeinfo %(extraopts) --html %t"
		     TeX-run-compile nil (texinfo-mode) :help
		     "Run Makeinfo with HTML output")
		    ("AmSTeX" "amstex %(PDFout) %(extraopts) %`%S%(mode)%' %t"
		     TeX-run-TeX nil (ams-tex-mode) :help "Run AMSTeX")
		    ("ConTeXt"
		     "%(cntxcom) --once --texutil %(extraopts) %(execopts)%t"
		     TeX-run-TeX nil (context-mode) :help "Run ConTeXt once")
		    ("ConTeXt Full" "%(cntxcom) %(extraopts) %(execopts)%t"
		     TeX-run-TeX nil (context-mode) :help
		     "Run ConTeXt until completion")
		    ("BibTeX" "bibtex %s" TeX-run-BibTeX nil t :help
		     "Run BibTeX")
		    ("Biber" "biber %s" TeX-run-Biber nil t :help "Run Biber")
		    ("View" "%V" TeX-run-discard-or-function t t :help
		     "Run Viewer")
		    ("Print" "%p" TeX-run-command t t :help "Print the file")
		    ("Queue" "%q" TeX-run-background nil t :help
		     "View the printer queue" :visible TeX-queue-command)
		    ("File" "%(o?)dvips %d -o %f " TeX-run-dvips t t :help
		     "Generate PostScript file")
		    ("Dvips" "%(o?)dvips %d -o %f " TeX-run-dvips nil t :help
		     "Convert DVI file to PostScript")
		    ("Dvipdfmx" "dvipdfmx %d" TeX-run-dvipdfmx nil t :help
		     "Convert DVI file to PDF with dvipdfmx")
		    ("Ps2pdf" "ps2pdf %f" TeX-run-ps2pdf nil t :help
		     "Convert PostScript file to PDF")
		    ("Index" "makeindex %s" TeX-run-index nil t :help
		     "Run makeindex to create index file")
		    ("Xindy" "texindy %s" TeX-run-command nil t :help
		     "Run xindy to create index file")
		    ("Check" "lacheck %s" TeX-run-compile nil (latex-mode)
		     :help "Check LaTeX file for correctness")
		    ("ChkTeX" "chktex -v6 %s" TeX-run-compile nil (latex-mode)
		     :help "Check LaTeX file for common mistakes")
		    ("Spell" "(TeX-ispell-document \"\")" TeX-run-function nil
		     t :help "Spell-check the document")
		    ("Clean" "TeX-clean" TeX-run-function nil t :help
		     "Delete generated intermediate files")
		    ("Clean All" "(TeX-clean t)" TeX-run-function nil t :help
		     "Delete generated intermediate and output files")
		    ("Other" "" TeX-run-command t t :help
		     "Run an arbitrary command")
		    )
 )

--- font-latex.el-pre	2017-01-25 16:22:26.647520000 -0800
+++ font-latex.el	2017-08-13 21:54:42.256744000 -0700
@@ -1895,6 +1895,8 @@ set to french, and >>german<< (and 8-bit
 		 (nest-count 0)
 		 (point-of-surrender (+ beg font-latex-multiline-boundary)))
 	    ;; Find closing quote taking nested quotes into account.
+	    (if (equal closing-quote "''")
+		(setq closing-quote "''\\|\""))
 	    (while (progn
 		     (re-search-forward
 		      (concat opening-quote "\\|" closing-quote)
@@ -1957,7 +1959,8 @@ END marks boundaries for searching for q
   "Match subscript and superscript patterns up to LIMIT."
   (when (and font-latex-fontify-script
 	     (re-search-forward "[_^] *\\([^\n\\{}]\\|\
-\\\\\\([a-zA-Z@]+\\|[^ \t\n]\\)\\|\\({\\)\\)" limit t))
+\\\\\\([a-zA-Z@]+\\|[^ \t\n]\\)\\|\\({\\)\\)" limit t)
+	     (not (get-text-property (match-beginning 0) 'composition)))
     (if (and (not (memq font-latex-fontify-script '(multi-level invisible)))
 	     (font-latex-faces-present-p '(font-latex-subscript-face
 					   font-latex-superscript-face)))
@@ -1981,6 +1984,7 @@ END marks boundaries for searching for q
 (defun font-latex-match-script-chars (limit)
   "Match subscript and superscript chars up to LIMIT."
   (and (re-search-forward "[^_^]\\([_^]\\)" limit t)
+       (not (get-text-property (match-beginning 1) 'composition))
        (let ((pos (match-beginning 1)))
 	 (and (font-latex-faces-present-p 'font-latex-math-face pos)
 	      (not (font-latex-faces-present-p '(font-lock-constant-face