[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/auctex 970787f92d 11/13: Improve paragraph commands man
From: |
ELPA Syncer |
Subject: |
[elpa] externals/auctex 970787f92d 11/13: Improve paragraph commands management for ConTeXt mode (bug#70811) |
Date: |
Wed, 15 May 2024 06:57:30 -0400 (EDT) |
branch: externals/auctex
commit 970787f92d21447296c474bee954ac1ac3e0b8de
Author: Ikumi Keita <ikumi@ikumi.que.jp>
Commit: Ikumi Keita <ikumi@ikumi.que.jp>
Improve paragraph commands management for ConTeXt mode (bug#70811)
* context.el (ConTeXt-paragraph-commands): New customize option similar
to LaTeX counterpart.
(ConTeXt-extra-paragraph-commands): Provide proper defvar.
(ConTeXt-paragraph-commands-regexp-make): Rename from
`ConTeXt-paragraph-commands-regexp' for consistency with latex.el.
Include `ConTeXt-paragraph-commands' to generate the regexp.
(ConTeXt-paragraph-commands-regexp): Add alias for backward
compatibility.
(ConTeXt-set-paragraph-start): Factor out following latex.el.
(ConTeXt-paragraph-commands-add-locally): New convinience function
similar to LaTeX counterpart.
(ConTeXt-mode-cleanup): Use new functions.
---
context.el | 63 +++++++++++++++++++++++++++++++++++++++++++++++---------------
1 file changed, 48 insertions(+), 15 deletions(-)
diff --git a/context.el b/context.el
index 0d5b9adbd1..8b0c88ee64 100644
--- a/context.el
+++ b/context.el
@@ -53,9 +53,6 @@
(require 'latex) ; for functions like `TeX-look-at' and `LaTeX-split-long-menu'
(require 'plain-tex) ; for `plain-TeX-common-initialization'
-;; Silence the compiler:
-(defvar ConTeXt-extra-paragraph-commands)
-
(defgroup ConTeXt-macro nil
"Special support for ConTeXt macros in AUCTeX."
:prefix "TeX-"
@@ -1121,18 +1118,59 @@ If OPTIONAL, only insert it if not empty, and then use
square brackets."
(defvar ConTeXt-item-list ()
"List of macro's considered items.")
-(defun ConTeXt-paragraph-commands-regexp ()
- "Return a regexp matching macros that should have their own line."
+(defvar ConTeXt-extra-paragraph-commands nil
+ "List of default ConTeXt macros that should begin their own line.
+Unlike `ConTeXt-paragraph-commands', each entry should be a regular
+expression without leading backslash.
+Updated in language-specific initialization.")
+
+(defcustom ConTeXt-paragraph-commands nil
+ "List of user ConTeXt macros that should begin their own line.
+The list should contain macro names without the leading backslash.
+
+If you change this variable, its value is reflected to only new buffers
+created afterwards; existing ConTeXt mode buffers aren't affected."
+ :group 'ConTeXt-macro
+ :type '(repeat (string)))
+
+(defun ConTeXt-paragraph-commands-regexp-make ()
+ "Return a regexp matching macros that should begin their own line."
(concat
- (regexp-quote TeX-esc) "\\("
+ (regexp-quote TeX-esc) "\\(?:"
"[][]\\|" ; display math delimitors (is this applicable to ConTeXt??)
(ConTeXt-environment-start-name) "\\|"
(ConTeXt-environment-stop-name) "\\|"
(mapconcat #'car ConTeXt-numbered-section-list "\\b\\|") "\\b\\|"
(mapconcat #'car ConTeXt-unnumbered-section-list "\\b\\|") "\\b\\|"
+ (mapconcat #'identity ConTeXt-paragraph-commands "\\b\\|") "\\b\\|"
(mapconcat #'identity ConTeXt-extra-paragraph-commands "\\b\\|")
"\\b\\|"
(mapconcat #'identity ConTeXt-item-list "\\b\\|") "\\b\\)"))
+;; Backward compatibility.
+(defalias 'ConTeXt-paragraph-commands-regexp
+ #'ConTeXt-paragraph-commands-regexp-make)
+
+(defun ConTeXt-set-paragraph-start ()
+ "Set `paragraph-start'."
+ (setq paragraph-start
+ (concat
+ "[ \t]*\\(?:"
+ LaTeX-paragraph-commands-regexp "\\|"
+ "\\$\\$\\|" ; Plain TeX display math
+ "$\\)")))
+
+(defun ConTeXt-paragraph-commands-add-locally (commands)
+ "Make COMMANDS be recognized as paragraph commands.
+COMMANDS can be a single string or a list of strings which will be added
+to `ConTeXt-extra-paragraph-commands'. Additionally
+`LaTeX-paragraph-commands-regexp' will be updated.
+This is mainly a convenience function which can be used in style files."
+ (unless (listp commands) (setq commands (list commands)))
+ (dolist (elt commands)
+ (add-to-list 'ConTeXt-extra-paragraph-commands elt))
+ (setq-local LaTeX-paragraph-commands-regexp
+ (ConTeXt-paragraph-commands-regexp-make))
+ (ConTeXt-set-paragraph-start))
;; Outline support
@@ -1908,16 +1946,11 @@ Run after mode hooks and file local variables
application."
(mapconcat #'identity ConTeXt-item-list "\\|")
"\\)\\>")))
- ;; Don't do locally-bound test for `LaTeX-paragraph-commands-regexp'
- ;; and `paragraph-start'. See comments in similar part in latex.el.
(setq-local LaTeX-paragraph-commands-regexp
- (ConTeXt-paragraph-commands-regexp))
- (setq paragraph-start
- (concat
- "[ \t]*\\("
- (ConTeXt-paragraph-commands-regexp) "\\|"
- "\\$\\$\\|" ; Plain TeX display math
- "$\\)")))
+ (ConTeXt-paragraph-commands-regexp-make))
+ ;; Don't do locally-bound test for `paragraph-start'. See comments in
+ ;; similar part in latex.el.
+ (ConTeXt-set-paragraph-start))
(defun context-guess-current-interface ()
"Guess what ConTeXt interface the current buffer is using."
- [elpa] externals/auctex bf7ceef14f 06/13: ; * NEWS.org: Update the file., (continued)
- [elpa] externals/auctex bf7ceef14f 06/13: ; * NEWS.org: Update the file., ELPA Syncer, 2024/05/15
- [elpa] externals/auctex cba5820cf8 03/13: Allow compilation messages to be suppressed, ELPA Syncer, 2024/05/15
- [elpa] externals/auctex a7f80ab858 10/13: Replace `TeX-arg-eval' in style/moodle.el, ELPA Syncer, 2024/05/15
- [elpa] externals/auctex 5f039df961 02/13: ; * NEWS.org: Update the file., ELPA Syncer, 2024/05/15
- [elpa] externals/auctex 543d92aa89 13/13: Merge remote-tracking branch 'origin/master', ELPA Syncer, 2024/05/15
- [elpa] externals/auctex 59ddea9f13 04/13: Correct variable name, ELPA Syncer, 2024/05/15
- [elpa] externals/auctex 61f8825cfd 05/13: Add new style/amsrefs.el, ELPA Syncer, 2024/05/15
- [elpa] externals/auctex 774974185a 07/13: Fix compilation on Emacs 27, ELPA Syncer, 2024/05/15
- [elpa] externals/auctex 7b9efc2e17 08/13: ; * style/amsrefs.el ("amsrefs"): Add the "biblist*" environment., ELPA Syncer, 2024/05/15
- [elpa] externals/auctex 600b92446f 09/13: ; * NEWS.org: Fix last change., ELPA Syncer, 2024/05/15
- [elpa] externals/auctex 970787f92d 11/13: Improve paragraph commands management for ConTeXt mode (bug#70811),
ELPA Syncer <=
- [elpa] externals/auctex e30189d92a 12/13: ; * NEWS.org: Update for 14.0.5 ELPA release., ELPA Syncer, 2024/05/15