[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 10dbae9a: Add support for catchfilebetweentags package
From: |
Arash Esbati |
Subject: |
master 10dbae9a: Add support for catchfilebetweentags package |
Date: |
Wed, 31 Aug 2022 03:07:50 -0400 (EDT) |
branch: master
commit 10dbae9ab1725eeb0452b5c4a36d5a25bb121040
Author: Uwe Brauer <oub@mat.ucm.es>
Commit: Arash Esbati <arash@gnu.org>
Add support for catchfilebetweentags package
* Makefile.in (STYLESRC): Add new style.
* tex-style.el (LaTeX-catchfilebetweentags-use-numeric-label):
Add a new variable that controls whether a numeric label gets
inserted automatically. Default is t.
* style/catchfilebetweentags.el: New file.
---
Makefile.in | 3 +-
style/catchfilebetweentags.el | 116 ++++++++++++++++++++++++++++++++++++++++++
tex-style.el | 7 +++
3 files changed, 125 insertions(+), 1 deletion(-)
diff --git a/Makefile.in b/Makefile.in
index 97ddae21..ffa39b25 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -194,7 +194,8 @@ STYLESRC = style/prosper.el \
style/ifpdf.el style/iftex.el style/ifvtex.el \
style/ifxetex.el style/multibib.el style/ltcaption.el \
style/keyval.el style/kvoptions.el style/kvsetkeys.el \
- style/proc.el style/microtype.el style/tcolorboxlib-theorems.el
+ style/proc.el style/microtype.el style/tcolorboxlib-theorems.el
\
+ style/catchfilebetweentags.el
STYLEELC = $(STYLESRC:.el=.elc)
diff --git a/style/catchfilebetweentags.el b/style/catchfilebetweentags.el
new file mode 100644
index 00000000..27c67e23
--- /dev/null
+++ b/style/catchfilebetweentags.el
@@ -0,0 +1,116 @@
+;;; catchfilebetweentags.el --- AUCTeX style for catchfilebetweentags package
-*- lexical-binding: t; -*-
+
+;; Copyright (C) 2022 Free Software Foundation, Inc.
+
+;; Author: Uwe Brauer <oub@mat.ucm.es>
+;; Maintainer: auctex-devel@gnu.org
+;; Created: Aug 23, 2022
+;; Keywords: tex
+
+;; This file is part of AUCTeX.
+
+;; AUCTeX is free software; you can redistribute it and/or modify it
+;; under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 3, or (at your option)
+;; any later version.
+
+;; AUCTeX is distributed in the hope that it will be useful, but
+;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+;; General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with AUCTeX; see the file COPYING. If not, write to the Free
+;; Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+;; 02110-1301, USA.
+
+;;; Commentary:
+
+;; This file adds support for the catchfilebetweentags package.
+
+;; Acknowledgements
+;; Arash Esbati <arash@gnu.org> for, basically, a complete rewrite, thanks.
+
+;;; Code:
+
+(require 'tex)
+(require 'latex)
+
+;; Silence the compiler:
+(declare-function font-latex-add-keywords
+ "font-latex"
+ (keywords class))
+
+(defvar-local LaTeX-catchfilebetweentags-counter nil
+ "Counter for LaTeX-catchfilebetweentags numbers.")
+
+;; Scanning function, stolen from markdown-mode
+(defun LaTeX-catchfilebetweentags-counter-inc ()
+ "Increment `LaTeX-catchfilebetweentags-counter' and return the new value."
+ (when (null LaTeX-catchfilebetweentags-counter)
+ (setq LaTeX-catchfilebetweentags-counter 0)
+ (save-excursion
+ (goto-char (point-min))
+ (while (re-search-forward (concat "^%<\\*\\([^>]+\\)>$")
+ (point-max) t)
+ (let ((fn (string-to-number (match-string 1))))
+ (when (> fn LaTeX-catchfilebetweentags-counter)
+ (setq LaTeX-catchfilebetweentags-counter fn))))))
+ (setq LaTeX-catchfilebetweentags-counter
+ (1+ LaTeX-catchfilebetweentags-counter)))
+
+(defun LaTeX-env-catchfilebetweentags (_environment)
+ "Insert a tag-skeleton defined by `LaTeX-catchfilebetweentags'.
+ENVIRONMENT is ignored."
+ (let* ((fn (when LaTeX-catchfilebetweentags-use-numeric-label
+ (LaTeX-catchfilebetweentags-counter-inc)))
+ (tag (TeX-read-string
+ (if fn (format "Tag (default %s): " fn) "Tag: ")
+ nil nil (when fn (number-to-string fn)))))
+ (unless (bolp)
+ (newline)
+ (delete-horizontal-space))
+ (save-excursion
+ (insert (concat (format "%%<*%s>" tag)
+ "\n\n"
+ (format "%%</%s>" tag)))))
+ (forward-line))
+
+(TeX-add-style-hook
+ "catchfilebetweentags"
+ (lambda ()
+ (TeX-add-symbols
+ '("ExecuteMetaData"
+ ;; Act like \include and not like \input:
+ [TeX-arg-input-file "File" t] "Tag")
+ '("ExecuteMetaData*"
+ [TeX-arg-input-file "File" t] "Tag")
+
+ '("CatchFileBetweenTags"
+ TeX-arg-define-macro (TeX-arg-input-file "File-name" t) "Tag")
+ '("CatchFileBetweenTags*"
+ TeX-arg-define-macro (TeX-arg-input-file "File-name" t) "Tag")
+
+ '("CatchFileBetweenDelims"
+ TeX-arg-define-macro (TeX-arg-input-file "File-name" t)
+ "Start delimiter" "Stop delimiter" ["Setup"]))
+
+ (LaTeX-add-environments
+ '("catchfilebetweenfiletags" LaTeX-env-catchfilebetweentags))
+
+ ;; Add `LaTeX-catchfilebetweentags-counter' to
+ ;; `TeX-normal-mode-reset-list' in case the variable gets out of
+ ;; sync:
+ (add-to-list 'TeX-normal-mode-reset-list
+ 'LaTeX-catchfilebetweentags-counter)
+
+ ;; Fontification
+ (when (and (featurep 'font-latex)
+ (eq TeX-install-font-lock 'font-latex-setup))
+ (font-latex-add-keywords '(("ExecuteMetaData" "*[{")
+ ("CatchFileBetweenTags" "*|{\\{{")
+ ("CatchFileBetweenDelims" "|{\\{{{["))
+ 'function)))
+ TeX-dialect)
+
+;;; catchfilebetweentags.el ends here
diff --git a/tex-style.el b/tex-style.el
index 3ef92d27..b880bfcc 100644
--- a/tex-style.el
+++ b/tex-style.el
@@ -226,6 +226,13 @@ override the autodetection of the biblatex backend.")
(make-variable-buffer-local 'LaTeX-biblatex-use-Biber)
(put 'LaTeX-biblatex-use-Biber 'safe-local-variable #'booleanp)
+;; style/catchfilebetweentags.el
+
+(defcustom LaTeX-catchfilebetweentags-use-numeric-label t
+ "If non-nil, insert automatic numerical labels.
+Otherwise the prompt asks for a label name."
+ :type 'boolean)
+
;; style/comment.el
(defcustom LaTeX-comment-env-list '("comment")
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master 10dbae9a: Add support for catchfilebetweentags package,
Arash Esbati <=