(defun latex-imenu-create-index ()
"Generate an alist for imenu from a LaTeX buffer."
(let ((section-regexp
- (concat "\\\\" (regexp-opt (mapcar 'car latex-section-alist) t)
+ (concat "\\\\" (regexp-opt (mapcar #'car latex-section-alist) t)
"\\*?[ \t]*{"))
(metasection-regexp
(concat "\\\\" (regexp-opt latex-metasection-list t)))
;; Using sexps allows some use of matching {...} inside
;; titles.
(forward-sexp 1)
- (push (cons (concat (apply 'concat
+ (push (cons (concat (apply #'concat
(make-list
(max 0 (- i i0))
latex-imenu-indent-string))
(defvar latex-outline-regexp
(concat "\\\\"
(regexp-opt (append latex-metasection-list
- (mapcar 'car latex-section-alist)) t)))
+ (mapcar #'car latex-section-alist))
+ t)))
(defun latex-outline-level ()
(if (looking-at latex-outline-regexp)
(let* (;;
;; Names of commands whose arg should be fontified with fonts.
(bold (regexp-opt '("textbf" "textsc" "textup"
- "boldsymbol" "pmb") t))
+ "boldsymbol" "pmb")
+ t))
(italic (regexp-opt '("textit" "textsl" "emph") t))
;; FIXME: unimplemented yet.
;; (type (regexp-opt '("texttt" "textmd" "textrm" "textsf") t))
'("linebreak" "nolinebreak" "pagebreak" "nopagebreak"
"newline" "newpage" "clearpage" "cleardoublepage"
"displaybreak" "allowdisplaybreaks"
- "enlargethispage") t))
+ "enlargethispage")
+ t))
(general "\\([a-zA-Z@]+\\**\\|[^ \t\n]\\)")
;;
;; Miscellany.
(defvar tex-verbatim-environments
'("verbatim" "verbatim*"))
(put 'tex-verbatim-environments 'safe-local-variable
- (lambda (x) (null (delq t (mapcar 'stringp x)))))
+ (lambda (x) (null (delq t (mapcar #'stringp x)))))
(eval-when-compile
(defconst tex-syntax-propertize-rules
(concat "[ \t]*\\(\\$\\$\\|"
"\\\\[][]\\|"
"\\\\" (regexp-opt (append
- (mapcar 'car latex-section-alist)
+ (mapcar #'car latex-section-alist)
'("begin" "label" "end"
"item" "bibitem" "newline" "noindent"
"newpage" "footnote" "marginpar"
- "parbox" "caption")) t)
+ "parbox" "caption"))
+ t)
"\\>\\|\\\\[a-z]*" (regexp-opt '("space" "skip" "page") t)
"\\>\\)"))
(setq paragraph-separate
(concat "[\f%]\\|[ \t]*\\($\\|"
"\\\\[][]\\|"
"\\\\" (regexp-opt (append
- (mapcar 'car latex-section-alist)
- '("begin" "label" "end" )) t)
+ (mapcar #'car latex-section-alist)
+ '("begin" "label" "end" ))
+ t)
"\\>\\|\\\\\\(" (regexp-opt '("item" "bibitem" "newline"
"noindent" "newpage" "footnote"
"marginpar" "parbox" "caption"))
"\\|\\$\\$\\|[a-z]*\\(space\\|skip\\|page[a-z]*\\)"
"\\>\\)[ \t]*\\($\\|%\\)\\)"))
- (setq-local imenu-create-index-function 'latex-imenu-create-index)
+ (setq-local imenu-create-index-function #'latex-imenu-create-index)
(setq-local tex-face-alist tex-latex-face-alist)
- (add-hook 'fill-nobreak-predicate 'latex-fill-nobreak-predicate nil t)
- (setq-local indent-line-function 'latex-indent)
+ (add-hook 'fill-nobreak-predicate #'latex-fill-nobreak-predicate nil t)
+ (setq-local indent-line-function #'latex-indent)
(setq-local fill-indent-according-to-mode t)
(add-hook 'completion-at-point-functions
- 'latex-complete-data nil 'local)
+ #'latex-complete-data nil 'local)
(setq-local outline-regexp latex-outline-regexp)
- (setq-local outline-level 'latex-outline-level)
- (setq-local forward-sexp-function 'latex-forward-sexp)
+ (setq-local outline-level #'latex-outline-level)
+ (setq-local forward-sexp-function #'latex-forward-sexp)
(setq-local skeleton-end-hook nil))
;;;###autoload
(defvar tildify-space-string)
(defvar tildify-foreach-region-function)
+(declare-function tildify-foreach-ignore-environments
+ "tildify" (pairs callback _beg end))
(defvar tex--prettify-symbols-alist)
(defun tex-common-initialization ()
;; rather than using regex-based filtering.
(setq-local tildify-foreach-region-function
(apply-partially
- 'tildify-foreach-ignore-environments
+ #'tildify-foreach-ignore-environments
`(("\\\\\\\\" . "") ; do not remove this
(,(eval-when-compile
(concat "\\\\begin{\\("
Puts point on a blank line between them."
(let ((choice (completing-read (format "LaTeX block name [%s]: "
latex-block-default)
- (append latex-block-names
- latex-standard-block-names)
+ (latex-complete-envnames)
nil nil nil nil latex-block-default)))
(setq latex-block-default choice)
(unless (or (member choice latex-standard-block-names)
(complete-with-action action keys key pred)))))
(defun latex-complete-envnames ()
- (append latex-block-names latex-standard-block-names))
+ (completion-table-in-turn
+ (append latex-block-names latex-standard-block-names)
+ (completion-table-dynamic
+ (lambda (str)
+ (with-current-buffer (if (and (minibufferp) (minibuffer-selected-window))
+ (window-buffer (minibuffer-selected-window))
+ (current-buffer))
+ (save-excursion
+ (let ((comps '())
+ (pos (point)))
+ (goto-char (point-min))
+ (while (re-search-forward (concat "\\\\begin{\\(" str "[^}\n ]*\\)")
+ nil t)
+ (unless (and (<= (match-beginning 0) pos)
+ (>= (match-end 0) pos))
+ (push (match-string 1) comps)))
+ comps)))))))
(defun latex-complete-refkeys ()
(when (boundp 'reftex-docstruct-symbol)
(symbol-value reftex-docstruct-symbol)))
(defvar latex-complete-alist
- ;; TODO: Add \begin, \end, \ref, ...
- '(("\\`\\\\\\(short\\)?cite\\'" . latex-complete-bibtex-keys)
- ("\\`\\\\\\(begin\\|end\\)\\'" . latex-complete-envnames)
- ("\\`\\\\[vf]?ref\\'" . latex-complete-refkeys)))
+ `(("\\`\\\\\\(short\\)?cite\\'" . ,#'latex-complete-bibtex-keys)
+ ("\\`\\\\\\(begin\\|end\\)\\'" . ,#'latex-complete-envnames)
+ ("\\`\\\\[vf]?ref\\'" . ,#'latex-complete-refkeys)))
(defun latex-complete-data ()
"Get completion-data at point."
(defun tex-summarize-command (cmd)
(if (not (stringp cmd)) ""
- (mapconcat 'identity
+ (mapconcat #'identity
(mapcar (lambda (s) (car (split-string s)))
(split-string cmd "\\s-*\\(?:;\\|&&\\)\\s-*"))
"&")))
;; Substitute and return.
(if (and hist-cmd
(string-match (concat "[' \t\"]" (format-spec "%r" fspec)
- "\\([;&' \t\"]\\|\\'\\)") hist-cmd))
+ "\\([;&' \t\"]\\|\\'\\)")
+ hist-cmd))
;; The history command was already applied to the same file,
;; so just reuse it.
hist-cmd
(defvar tex-indent-item-re "\\\\\\(bib\\)?item\\>")
(defvar latex-noindent-environments '("document"))
(put 'latex-noindent-environments 'safe-local-variable
- (lambda (x) (null (delq t (mapcar 'stringp x)))))
+ (lambda (x) (null (delq t (mapcar #'stringp x)))))
(defvar tex-latex-indent-syntax-table
(let ((st (make-syntax-table tex-mode-syntax-table)))