[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 316550f0 2/3: Fix `ConTeXt-add-environments'
From: |
Ikumi Keita |
Subject: |
master 316550f0 2/3: Fix `ConTeXt-add-environments' |
Date: |
Wed, 9 Nov 2022 10:01:08 -0500 (EST) |
branch: master
commit 316550f0bfa61d197fca7b4a9fc9b864b1b46640
Author: Ikumi Keita <ikumi@ikumi.que.jp>
Commit: Ikumi Keita <ikumi@ikumi.que.jp>
Fix `ConTeXt-add-environments'
* context.el (ConTeXt-environment, ConTeXt-environment-menu): Use
function `ConTeXt-environment-list' to refer to the current
environments list.
(ConTeXt-environment-menu): Follow `LaTeX-environment-menu' to support
optional argument for environments.
* tex.el (TeX-auto-add-type): Use unique key for `TeX-auto-parser' in
order to discriminate ConTeXt environments from LaTeX environments.
* context-en.el (ConTeXt-en-mode-initialization):
* context-nl.el (ConTeXt-nl-mode-initialization):
Add comments.
---
context-en.el | 5 ++++-
context-nl.el | 5 ++++-
context.el | 25 ++++++++++++++-----------
tex.el | 12 ++++++++----
4 files changed, 30 insertions(+), 17 deletions(-)
diff --git a/context-en.el b/context-en.el
index f4b8fdf8..54f30da3 100644
--- a/context-en.el
+++ b/context-en.el
@@ -1,7 +1,7 @@
;;; context-en.el --- Support for the ConTeXt english interface. -*-
lexical-binding: t; -*-
;; Copyright (C) 2003-2004, 2006, 2008
-;; 2010, 2014, 2020, 2021 Free Software Foundation, Inc.
+;; 2010, 2014, 2020-2022 Free Software Foundation, Inc.
;; Maintainer: Berend de Boer <berend@pobox.com>
;; Keywords: tex
@@ -188,6 +188,9 @@ That is, besides the section(-block) commands.")
(defun ConTeXt-en-mode-initialization ()
"ConTeXt english interface specific initialization."
+ ;; FIXME: This `mapc' seems spurious because
+ ;; `ConTeXt-language-variable-list' includes
+ ;; `ConTeXt-environment-list'.
(mapc #'ConTeXt-add-environments (reverse ConTeXt-environment-list-en))
(TeX-add-symbols
diff --git a/context-nl.el b/context-nl.el
index 9b49cce2..143a18a3 100644
--- a/context-nl.el
+++ b/context-nl.el
@@ -1,7 +1,7 @@
;;; context-nl.el --- Support for the ConTeXt dutch interface. -*-
lexical-binding: t; -*-
;; Copyright (C) 2003, 2004, 2006, 2010,
-;; 2015, 2020, 2021 Free Software Foundation, Inc.
+;; 2015, 2020-2022 Free Software Foundation, Inc.
;; Maintainer: Berend de Boer <berend@pobox.com>
;; Keywords: tex
@@ -163,6 +163,9 @@ That is, besides the section(-block) commands.")
(defun ConTeXt-nl-mode-initialization ()
"ConTeXt dutch interface specific initialization."
+ ;; FIXME: This `mapc' seems spurious because
+ ;; `ConTeXt-language-variable-list' includes
+ ;; `ConTeXt-environment-list'.
(mapc #'ConTeXt-add-environments (reverse ConTeXt-environment-list-nl))
(TeX-add-symbols
diff --git a/context.el b/context.el
index 50fb1adf..40eacda8 100644
--- a/context.el
+++ b/context.el
@@ -680,14 +680,14 @@ With optional ARG, modify current environment."
(t ConTeXt-default-environment)))
(environment
(completing-read (concat "Environment type (default " default "): ")
- ConTeXt-environment-list nil nil nil
+ (ConTeXt-environment-list) nil nil nil
'ConTeXt-environment-history default)))
;; Use `environment' as default for the next time only if it is different
;; from the current default.
(unless (equal environment default)
(setq ConTeXt-default-environment environment))
- (let ((entry (assoc environment ConTeXt-environment-list)))
+ (let ((entry (assoc environment (ConTeXt-environment-list))))
(if (null entry)
(ConTeXt-add-environments (list environment)))
@@ -717,7 +717,7 @@ With optional ARG, modify current environment."
(defun ConTeXt-environment-menu (environment)
"Insert ENVIRONMENT around point or region."
- (let ((entry (assoc environment ConTeXt-environment-list)))
+ (let ((entry (assoc environment (ConTeXt-environment-list))))
(cond ((not (and entry (nth 1 entry)))
(ConTeXt-insert-environment environment))
((numberp (nth 1 entry))
@@ -727,16 +727,19 @@ With optional ARG, modify current environment."
(setq args (concat args TeX-grop TeX-grcl))
(setq count (- count 1)))
(ConTeXt-insert-environment environment args)))
- ((stringp (nth 1 entry))
+ ((or (stringp (nth 1 entry)) (vectorp (nth 1 entry)))
(let ((prompts (cdr entry))
(args ""))
- (while prompts
- (setq args (concat args
- TeX-grop
- (read-from-minibuffer
- (concat (car prompts) ": "))
- TeX-grcl))
- (setq prompts (cdr prompts)))
+ (dolist (elt prompts)
+ (let* ((optional (vectorp elt))
+ (elt (if optional (elt elt 0) elt))
+ (arg (TeX-read-string
+ (TeX-argument-prompt optional elt nil))))
+ (setq args (concat args
+ (cond ((and optional (> (length arg) 0))
+ (concat ConTeXt-optop arg
ConTeXt-optcl))
+ ((not optional)
+ (concat TeX-grop arg TeX-grcl)))))))
(ConTeXt-insert-environment environment args)))
(t
(apply (nth 1 entry) environment (nthcdr 2 entry))))))
diff --git a/tex.el b/tex.el
index 317b8b49..5cb86af1 100644
--- a/tex.el
+++ b/tex.el
@@ -3918,7 +3918,10 @@ separate type of information in the parser."
(change (intern (concat prefix "-" name "-changed")))
(vardoc (concat "Information about " names
" in the current buffer.
-Generated by `TeX-auto-add-type'.")))
+Generated by `TeX-auto-add-type'."))
+ ;; Avoid clash between LaTeX environments and ConTeXt
+ ;; environments in keys of `TeX-auto-parser'.
+ (unique-key (concat prefix "-" name)))
`(progn
(defvar ,tmp nil ,vardoc)
(defvar ,local nil ,vardoc)
@@ -3929,15 +3932,16 @@ Generated by `TeX-auto-add-type'.")))
,(concat "Add information about " (upcase names)
" to the current buffer.
Generated by `TeX-auto-add-type'.")
- (TeX-auto-add-information ,name ,(intern names)))
+ (TeX-auto-add-information ,unique-key ,(intern names)))
(defun ,local ()
,(concat "List of " names
" active in the current buffer.
Generated by `TeX-auto-add-type'.")
- (TeX-auto-list-information ,name))
+ (TeX-auto-list-information ,unique-key))
;; Append new type to `TeX-auto-parser' in order to make `style' type
;; always the first.
- (add-to-list 'TeX-auto-parser ',(list name tmp add local change) t)
+ (add-to-list 'TeX-auto-parser
+ ',(list unique-key tmp add local change) t)
(add-hook 'TeX-remove-style-hook
(lambda ()
(setq ,local nil))))))
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master 316550f0 2/3: Fix `ConTeXt-add-environments',
Ikumi Keita <=