auctex-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[AUCTeX-diffs] GNU AUCTeX branch, lexical-binding-attempt-1, created. ed


From: Tassilo Horn
Subject: [AUCTeX-diffs] GNU AUCTeX branch, lexical-binding-attempt-1, created. ed732358227aafba4c1cd00490ae081393bff337
Date: Fri, 4 Sep 2020 11:24:46 -0400 (EDT)

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU AUCTeX".

The branch, lexical-binding-attempt-1 has been created
        at  ed732358227aafba4c1cd00490ae081393bff337 (commit)

- Log -----------------------------------------------------------------
commit ed732358227aafba4c1cd00490ae081393bff337
Author: Tassilo Horn <tsdh@gnu.org>
Date:   Fri Sep 4 17:19:57 2020 +0200

    Make dynamically bound latex/context vars proper special vars
    
    This affects in latex.el
      LaTeX-done-mark
      LaTeX-level
      LaTeX-name
      LaTeX-title
      LaTeX-toc
    
    and in context.el
      ConTeXt-done-mark
      ConTeXt-level
      ConTeXt-name
      ConTeXt-title
      ConTeXt-reference
    
    which were previously neither prefixed nor declared.

diff --git a/context.el b/context.el
index 626da22..caea30b 100644
--- a/context.el
+++ b/context.el
@@ -64,24 +64,6 @@
   :group 'ConTeXt
   :group 'TeX-macro)
 
-
-;;; variables
-
-;; Dynamically scoped vars used in certain macro's.
-;; BEWARE: We used to give them a global nil value, but this can mess up poor
-;; unrelated packages using those same vars but expecting them to be
-;; lexically scoped.
-;; So don't give them a global value, which makes sure the effect of `defvar'
-;; localized to this file!
-;; N.B.: These forms are commented out since they produce a "lack of
-;; prefix" warning during byte-compilation.  This way they produce
-;; only a "reference to free variable" one.
-;; (defvar done-mark) ; Position of point afterwards, default nil (meaning end)
-;; (defvar reference) ; Used by `ConTeXt-section-ref' and 
`ConTeXt-section-section'.
-;; (defvar title) ; Used by `ConTeXt-section-title' and 
`ConTeXt-section-section'.
-;; (defvar name)
-;; (defvar level)
-
 ;; others
 
 (defvar ConTeXt-known-interfaces '("cz" "de" "en" "it" "nl" "ro" "uk"))
@@ -271,6 +253,13 @@
 
 ;;; Sections
 
+;; Declare dynamically scoped vars.
+(defvar ConTeXt-title nil "Dynamically bound by `ConTeXt-section'.")
+(defvar ConTeXt-name nil "Dynamically bound by `ConTeXt-section'.")
+(defvar ConTeXt-level nil "Dynamically bound by `ConTeXt-section'.")
+(defvar ConTeXt-done-mark nil "Dynamically bound by `ConTeXt-section'.")
+(defvar ConTeXt-reference nil "Dynamically bound by `ConTeXt-section'.")
+
 (defun ConTeXt-section (arg)
   "Insert a template for a ConTeXt section.
 Determinate the type of section to be inserted, by the argument ARG.
@@ -301,23 +290,23 @@ The following variables can be set to customize:
 
   (interactive "*P")
   (let* ((val (prefix-numeric-value arg))
-        (level (cond ((null arg)
-                      (ConTeXt-current-section))
-                     ((listp arg)
-                      (ConTeXt-down-section))
-                     ((< val 0)
-                      (ConTeXt-up-section (- val)))
-                     (t val)))
-        (name (ConTeXt-numbered-section-name level))
-        (title "")
-         (reference nil)
-        (done-mark (make-marker)))
+        (ConTeXt-level (cond ((null arg)
+                              (ConTeXt-current-section))
+                             ((listp arg)
+                              (ConTeXt-down-section))
+                             ((< val 0)
+                              (ConTeXt-up-section (- val)))
+                             (t val)))
+        (ConTeXt-name (ConTeXt-numbered-section-name ConTeXt-level))
+        (ConTeXt-title "")
+         (ConTeXt-reference nil)
+        (ConTeXt-done-mark (make-marker)))
     (newline)
     (run-hooks 'ConTeXt-numbered-section-hook)
     (newline)
-    (if (marker-position done-mark)
-       (goto-char (marker-position done-mark)))
-    (set-marker done-mark nil)))
+    (if (marker-position ConTeXt-done-mark)
+       (goto-char (marker-position ConTeXt-done-mark)))
+    (set-marker ConTeXt-done-mark nil)))
 
 ;; LaTeX has a max function here, which makes no sense.
 ;; I think you want to insert a section that is max ConTeXt-largest-level
@@ -417,22 +406,24 @@ section."
 
 The following variables are set before the hooks are run
 
-`level' - numeric section level, see the documentation of `ConTeXt-section'.
-`name' - name of the sectioning command, derived from `level'.
-`title' - The title of the section, default to an empty string.
-`done-mark' - Position of point afterwards, default nil (meaning end).
+`ConTeXt-level' - numeric section level, see the documentation of 
`ConTeXt-section'.
+`ConTeXt-name' - name of the sectioning command, derived from `level'.
+`ConTeXt-title' - The title of the section, default to an empty string.
+`ConTeXt-done-mark' - Position of point afterwards, default nil (meaning end).
 
 The following standard hook exist -
 
-ConTeXt-section-heading: Query the user about the name of the
-sectioning command.  Modifies `level' and `name'.
+ConTeXt-numbered-section-heading: Query the user about the name
+of the sectioning command.  Modifies `ConTeXt-level' and
+`ConTeXt-name'.
 
 ConTeXt-section-title: Query the user about the title of the
-section.  Modifies `title'.
+section.  Modifies `ConTeXt-title'.
 
-ConTeXt-section-section: Insert ConTeXt section command according to
-`name', `title', and `reference'.  If `title' is an empty string,
-`done-mark' will be placed at the point they should be inserted.
+ConTeXt-section-section: Insert ConTeXt section command according
+to `ConTeXt-name', `ConTeXt-title', and `LaTeX-reference'.  If
+`ConTeXt-title' is an empty string, `ConTeXt-done-mark' will be
+placed at the point they should be inserted.
 
 ConTeXt-section-ref: Insert a reference for this section command.
 
@@ -463,22 +454,24 @@ in your .emacs file."
 
 The following variables are set before the hooks are run
 
-`level' - numeric section level, see the documentation of `ConTeXt-section'.
-`name' - name of the sectioning command, derived from `level'.
-`title' - The title of the section, default to an empty string.
-`done-mark' - Position of point afterwards, default nil (meaning end).
+`ConTeXt-level' - numeric section level, see the documentation of 
`ConTeXt-section'.
+`ConTeXt-name' - name of the sectioning command, derived from `ConTeXt-level'.
+`ConTeXt-title' - The title of the section, default to an empty string.
+`ConTeXt-done-mark' - Position of point afterwards, default nil (meaning end).
 
 The following standard hook exist -
 
-ConTeXt-section-heading: Query the user about the name of the
-sectioning command.  Modifies `level' and `name'.
+ConTeXt-unnumbered-section-heading: Query the user about the name
+of the sectioning command.  Modifies `ConTeXt-level' and
+`ConTeXt-name'.
 
 ConTeXt-section-title: Query the user about the title of the
-section.  Modifies `title'.
+section.  Modifies `ConTeXt-title'.
 
-ConTeXt-section-section: Insert ConTeXt section command according to
-`name', `title', and `reference'.  If `title' is an empty string,
-`done-mark' will be placed at the point they should be inserted.
+ConTeXt-section-section: Insert ConTeXt section command according
+to `ConTeXt-name', `ConTeXt-title', and `LaTeX-reference'.  If
+`ConTeXt-title' is an empty string, `ConTeXt-done-mark' will be
+placed at the point they should be inserted.
 
 ConTeXt-section-ref: Insert a reference for this section command.
 
@@ -512,48 +505,49 @@ in your .emacs file."
 Insert this hook into `ConTeXt-numbered-section-hook' to allow the user to 
change
 the name of the sectioning command inserted with `\\[ConTeXt-section]'."
   (let ((string (completing-read
-                (concat "Select level (default " name "): ")
+                (concat "Select level (default " ConTeXt-name "): ")
                 ConTeXt-numbered-section-list
                 nil nil nil)))
     ;; Update name
     (if (not (zerop (length string)))
-       (setq name string))))
+       (setq ConTeXt-name string))))
 
 (defun ConTeXt-unnumbered-section-heading ()
   "Hook to prompt for ConTeXt section name.
 Insert this hook into `ConTeXt-unnumbered-section-hook' to allow the user to 
change
 the name of the sectioning command inserted with `\\[ConTeXt-section]'."
   (let ((string (completing-read
-                (concat "Select level (default " name "): ")
+                (concat "Select level (default " ConTeXt-name "): ")
                 ConTeXt-unnumbered-section-list
                 nil nil nil)))
     ;; Update name
     (if (not (zerop (length string)))
-       (setq name string))))
+       (setq ConTeXt-name string))))
 
 (defun ConTeXt-section-title ()
   "Hook to prompt for ConTeXt section title.
 Insert this hook into `ConTeXt-(un)numbered-section-hook' to allow the user to 
change
 the title of the section inserted with `\\[ConTeXt-section]."
-  (setq title (TeX-read-string "What title: ")))
+  (setq ConTeXt-title (TeX-read-string "What title: ")))
 
 (defun ConTeXt-section-section ()
   "Hook to insert ConTeXt section command into the file.
-Insert this hook into `ConTeXt-section-hook' after those hooks which sets
-the `name', `title', and `reference' variables, but before those hooks which
+Insert this hook into `ConTeXt-section-hook' after those hooks
+which sets the `ConTeXt-name', `ConTeXt-title', and
+`ConTeXt-reference' variables, but before those hooks which
 assumes the section already is inserted."
-  (insert TeX-esc name)
-  (cond ((null reference))
-       ((zerop (length reference))
+  (insert TeX-esc ConTeXt-name)
+  (cond ((null ConTeXt-reference))
+       ((zerop (length ConTeXt-reference))
         (insert ConTeXt-optop)
-        (set-marker done-mark (point))
+        (set-marker ConTeXt-done-mark (point))
         (insert ConTeXt-optcl))
        (t
-        (insert ConTeXt-optop reference ConTeXt-optcl)))
+        (insert ConTeXt-optop ConTeXt-reference ConTeXt-optcl)))
   (insert TeX-grop)
-  (if (zerop (length title))
-      (set-marker done-mark (point)))
-  (insert title TeX-grcl)
+  (if (zerop (length ConTeXt-title))
+      (set-marker ConTeXt-done-mark (point)))
+  (insert ConTeXt-title TeX-grcl)
   (newline)
   ;; If RefTeX is available, tell it that we've just made a new section
   (and (fboundp 'reftex-notice-new-section)
@@ -563,13 +557,14 @@ assumes the section already is inserted."
   "Hook to insert a reference after the sectioning command.
 Insert this hook into `ConTeXt-section-hook' to prompt for a label to be
 inserted after the sectioning command."
-  (setq reference (completing-read
-                  (TeX-argument-prompt t nil
-                                       "Comma separated list of references")
-                  (LaTeX-label-list) nil nil))
+  (setq ConTeXt-reference
+        (completing-read
+        (TeX-argument-prompt t nil
+                             "Comma separated list of references")
+        (LaTeX-label-list) nil nil))
   ;; No reference or empty string entered?
-  (if (string-equal "" reference)
-      (setq reference nil)))
+  (if (string-equal "" ConTeXt-reference)
+      (setq ConTeXt-reference nil)))
 
 
 ;; Various
diff --git a/doc/auctex.texi b/doc/auctex.texi
index b19b60d..2c5f269 100644
--- a/doc/auctex.texi
+++ b/doc/auctex.texi
@@ -770,16 +770,16 @@ List of hooks to run when a new section is inserted.
 The following variables are set before the hooks are run
 
 @table @var
-@item level
+@item LaTeX-level
 Numeric section level, default set by prefix arg to
 @code{LaTeX-section}.
-@item name
+@item LaTeX-name
 Name of the sectioning command, derived from @var{level}.
-@item title
+@item LaTeX-title
 The title of the section, default to an empty string.
-@item toc
+@item LaTeX-toc
 Entry for the table of contents list, default nil.
-@item done-mark
+@item LaTeX-done-mark
 Position of point afterwards, default nil meaning after the inserted
 text.
 @end table
@@ -790,16 +790,17 @@ get the desired functionality by choosing from these 
hooks.
 @ftable @code
 @item LaTeX-section-heading
 Query the user about the name of the sectioning command.  Modifies
-@var{level} and @var{name}.
+@var{LaTeX-level} and @var{LaTeX-name}.
 @item LaTeX-section-title
-Query the user about the title of the section. Modifies @var{title}.
+Query the user about the title of the section. Modifies @var{LaTeX-title}.
 @item LaTeX-section-toc
-Query the user for the toc entry.  Modifies @var{toc}.
+Query the user for the toc entry.  Modifies @var{LaTeX-toc}.
 @item LaTeX-section-section
-Insert @LaTeX{} section command according to @var{name}, @var{title},
-and @var{toc}.  If @var{toc} is nil, no toc entry is inserted.  If
-@var{toc} or @var{title} are empty strings, @var{done-mark} will be
-placed at the point they should be inserted.
+Insert @LaTeX{} section command according to @var{LaTeX-name},
+@var{LaTeX-title}, and @var{LaTeX-toc}.  If @var{LaTeX-toc} is nil, no
+toc entry is inserted.  If @var{LaTeX-toc} or @var{LaTeX-title} are
+empty strings, @var{LaTeX-done-mark} will be placed at the point they
+should be inserted.
 @item LaTeX-section-label
 Insert a label after the section command.  Controlled by the variable
 @code{LaTeX-section-label}.
diff --git a/latex.el b/latex.el
index 923d27a..4472c3b 100644
--- a/latex.el
+++ b/latex.el
@@ -127,14 +127,11 @@ This depends on `LaTeX-insert-into-comments'."
 ;;; Sections
 
 ;; Declare dynamically scoped vars.
-;; N.B.: These forms are commented out since they produce a "lack of
-;; prefix" warning during byte-compilation.  This way they produce
-;; only a "reference to free variable" one.
-;; (defvar title)
-;; (defvar name)
-;; (defvar level)
-;; (defvar done-mark)
-;; (defvar toc)
+(defvar LaTeX-title nil "Dynamically bound by `LaTeX-section'.")
+(defvar LaTeX-name nil "Dynamically bound by `LaTeX-section'.")
+(defvar LaTeX-level nil "Dynamically bound by `LaTeX-section'.")
+(defvar LaTeX-done-mark nil "Dynamically bound by `LaTeX-section'.")
+(defvar LaTeX-toc nil "Dynamically bound by `LaTeX-section'.")
 
 (defun LaTeX-section (arg)
   "Insert a template for a LaTeX section.
@@ -160,25 +157,25 @@ The following variables can be set to customize:
 
   (interactive "*P")
   (let* ((val (prefix-numeric-value arg))
-        (level (cond ((null arg)
-                      (LaTeX-current-section))
-                     ((listp arg)
-                      (LaTeX-down-section))
-                     ((< val 0)
-                      (LaTeX-up-section (- val)))
-                     (t val)))
-        (name (LaTeX-section-name level))
-        (toc nil)
-        (title (if (TeX-active-mark)
-                   (buffer-substring (region-beginning)
-                                     (region-end))
-                 ""))
-        (done-mark (make-marker)))
+        (LaTeX-level (cond ((null arg)
+                            (LaTeX-current-section))
+                           ((listp arg)
+                            (LaTeX-down-section))
+                           ((< val 0)
+                            (LaTeX-up-section (- val)))
+                           (t val)))
+        (LaTeX-name (LaTeX-section-name LaTeX-level))
+        (LaTeX-toc nil)
+        (LaTeX-title (if (TeX-active-mark)
+                         (buffer-substring (region-beginning)
+                                           (region-end))
+                       ""))
+        (LaTeX-done-mark (make-marker)))
     (run-hooks 'LaTeX-section-hook)
     (LaTeX-newline)
-    (if (marker-position done-mark)
-       (goto-char (marker-position done-mark)))
-    (set-marker done-mark nil)))
+    (if (marker-position LaTeX-done-mark)
+       (goto-char (marker-position LaTeX-done-mark)))
+    (set-marker LaTeX-done-mark nil)))
 
 (defun LaTeX-current-section ()
   "Return the level of the section that contain point.
@@ -371,34 +368,35 @@ If so, return the second element, otherwise return nil."
 (defcustom LaTeX-section-hook
   '(LaTeX-section-heading
     LaTeX-section-title
-;; LaTeX-section-toc           ; Most people won't want this
+    ;; LaTeX-section-toc               ; Most people won't want this
     LaTeX-section-section
     LaTeX-section-label)
   "List of hooks to run when a new section is inserted.
 
 The following variables are set before the hooks are run
 
-level - numeric section level, see the documentation of `LaTeX-section'.
-name - name of the sectioning command, derived from `level'.
-title - The title of the section, default to an empty string.
-toc - Entry for the table of contents list, default nil.
-done-mark - Position of point afterwards, default nil (meaning end).
+LaTeX-level - numeric section level, see the documentation of `LaTeX-section'.
+LaTeX-name - name of the sectioning command, derived from `LaTeX-level'.
+LaTeX-title - The title of the section, default to an empty string.
+LaTeX-toc - Entry for the table of contents list, default nil.
+LaTeX-done-mark - Position of point afterwards, default nil (meaning end).
 
 The following standard hook exist -
 
 LaTeX-section-heading: Query the user about the name of the
-sectioning command.  Modifies `level' and `name'.
+sectioning command.  Modifies `LaTeX-level' and `LaTeX-name'.
 
 LaTeX-section-title: Query the user about the title of the
-section.  Modifies `title'.
+section.  Modifies `LaTeX-title'.
 
 LaTeX-section-toc: Query the user for the toc entry.  Modifies
-`toc'.
+`LaTeX-toc'.
 
 LaTeX-section-section: Insert LaTeX section command according to
-`name', `title', and `toc'.  If `toc' is nil, no toc entry is
-inserted.  If `toc' or `title' are empty strings, `done-mark' will be
-placed at the point they should be inserted.
+`LaTeX-name', `LaTeX-title', and `LaTeX-toc'.  If `LaTeX-toc' is
+nil, no toc entry is inserted.  If `LaTeX-toc' or `LaTeX-title'
+are empty strings, `LaTeX-done-mark' will be placed at the point
+they should be inserted.
 
 LaTeX-section-label: Insert a label after the section command.
 Controled by the variable `LaTeX-section-label'.
@@ -458,20 +456,20 @@ no label is inserted."
 Insert this hook into `LaTeX-section-hook' to allow the user to change
 the name of the sectioning command inserted with `\\[LaTeX-section]'."
   (let ((string (completing-read
-                (concat "Level (default " name "): ")
+                (concat "Level (default " LaTeX-name "): ")
                 LaTeX-section-list
-                nil nil nil nil name)))
-    ;; Update name
+                nil nil nil nil LaTeX-name)))
+    ;; Update LaTeX-name
     (if (not (zerop (length string)))
-       (setq name string))
+       (setq LaTeX-name string))
     ;; Update level
-    (setq level (LaTeX-section-level name))))
+    (setq LaTeX-level (LaTeX-section-level LaTeX-name))))
 
 (defun LaTeX-section-title ()
   "Hook to prompt for LaTeX section title.
 Insert this hook into `LaTeX-section-hook' to allow the user to change
 the title of the section inserted with `\\[LaTeX-section]."
-  (setq title (TeX-read-string "Title: " title))
+  (setq LaTeX-title (TeX-read-string "Title: " LaTeX-title))
   (let ((region (and (TeX-active-mark)
                     (cons (region-beginning) (region-end)))))
     (when region (delete-region (car region) (cdr region)))))
@@ -480,15 +478,16 @@ the title of the section inserted with 
`\\[LaTeX-section]."
   "Hook to prompt for the LaTeX section entry in the table of content .
 Insert this hook into `LaTeX-section-hook' to allow the user to insert
 a different entry for the section in the table of content."
-  (setq toc (TeX-read-string "Toc Entry: "))
-  (if (zerop (length toc))
-      (setq toc nil)))
+  (setq LaTeX-toc (TeX-read-string "Toc Entry: "))
+  (if (zerop (length LaTeX-toc))
+      (setq LaTeX-toc nil)))
 
 (defun LaTeX-section-section ()
   "Hook to insert LaTeX section command into the file.
-Insert this hook into `LaTeX-section-hook' after those hooks that set
-the `name', `title', and `toc' variables, but before those hooks that
-assume that the section is already inserted."
+Insert this hook into `LaTeX-section-hook' after those hooks that
+set the `LaTeX-name', `LaTeX-title', and `LaTeX-toc' variables,
+but before those hooks that assume that the section is already
+inserted."
   ;; insert a new line if the current line and the previous line are
   ;; not empty (except for whitespace), with one exception: do not
   ;; insert a new line if the previous (or current, sigh) line starts
@@ -499,18 +498,18 @@ assume that the section is already inserted."
                     "begin")
             (line-beginning-position 0) t))
     (LaTeX-newline))
-  (insert TeX-esc name)
-  (cond ((null toc))
-       ((zerop (length toc))
+  (insert TeX-esc LaTeX-name)
+  (cond ((null LaTeX-toc))
+       ((zerop (length LaTeX-toc))
         (insert LaTeX-optop)
-        (set-marker done-mark (point))
+        (set-marker LaTeX-done-mark (point))
         (insert LaTeX-optcl))
        (t
-        (insert LaTeX-optop toc LaTeX-optcl)))
+        (insert LaTeX-optop LaTeX-toc LaTeX-optcl)))
   (insert TeX-grop)
-  (if (zerop (length title))
-      (set-marker done-mark (point)))
-  (insert title TeX-grcl)
+  (if (zerop (length LaTeX-title))
+      (set-marker LaTeX-done-mark (point)))
+  (insert LaTeX-title TeX-grcl)
   (LaTeX-newline)
   ;; If RefTeX is available, tell it that we've just made a new section
   (and (fboundp 'reftex-notice-new-section)
@@ -522,7 +521,7 @@ Insert this hook into `LaTeX-section-hook' to prompt for a 
label to be
 inserted after the sectioning command.
 
 The behaviour of this hook is controlled by variable `LaTeX-section-label'."
-  (and (LaTeX-label name 'section)
+  (and (LaTeX-label LaTeX-name 'section)
        (LaTeX-newline)))
 
 ;;; Environments

-----------------------------------------------------------------------


hooks/post-receive
-- 
GNU AUCTeX



reply via email to

[Prev in Thread] Current Thread [Next in Thread]