auctex-diffs
[Top][All Lists]
Advanced

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

[AUCTeX-diffs] Changes to auctex/context.el,v


From: Berend de Boer
Subject: [AUCTeX-diffs] Changes to auctex/context.el,v
Date: Wed, 05 Jun 2013 22:20:48 +0000

CVSROOT:        /cvsroot/auctex
Module name:    auctex
Changes by:     Berend de Boer <berenddeboer>   13/06/05 22:20:46

Index: context.el
===================================================================
RCS file: /cvsroot/auctex/auctex/context.el,v
retrieving revision 1.77
retrieving revision 1.78
diff -u -b -r1.77 -r1.78
--- context.el  4 Dec 2012 08:01:33 -0000       1.77
+++ context.el  5 Jun 2013 22:20:45 -0000       1.78
@@ -301,12 +301,12 @@
                      ((< val 0)
                       (ConTeXt-up-section (- val)))
                      (t val)))
-        (name (ConTeXt-section-name level))
+        (name (ConTeXt-numbered-section-name level))
         (toc nil)
         (title "")
         (done-mark (make-marker)))
     (newline)
-    (run-hooks 'ConTeXt-section-hook)
+    (run-hooks 'ConTeXt-numbered-section-hook)
     (newline)
     (if (marker-position done-mark)
        (goto-char (marker-position done-mark)))
@@ -356,22 +356,44 @@
                                        nil t)))
        (ConTeXt-up-section (1- arg))))))
 
-(defvar ConTeXt-section-list ()
+(defvar ConTeXt-numbered-section-list ()
   "ConTeXt-XX-section-list where XX is the current interface.")
 
-(defun ConTeXt-section-name (level)
+(defvar ConTeXt-unnumbered-section-list ()
+  "ConTeXt-XX-section-list where XX is the current interface.")
+
+(defvar ConTeXt-section-list
+  (append ConTeXt-numbered-section-list ConTeXt-unnumbered-section-list)
+)
+
+(defun ConTeXt-numbered-section-name (level)
+  "Return the name of the section corresponding to LEVEL."
+  (let ((entry (TeX-member level ConTeXt-numbered-section-list
+                          (function (lambda (a b) (equal a (nth 1 b)))))))
+    (if entry
+       (nth 0 entry)
+      nil)))
+
+(defun ConTeXt-unnumbered-section-name (level)
   "Return the name of the section corresponding to LEVEL."
-  (let ((entry (TeX-member level ConTeXt-section-list
+  (let ((entry (TeX-member level ConTeXt-unnumbered-section-list
                           (function (lambda (a b) (equal a (nth 1 b)))))))
     (if entry
        (nth 0 entry)
       nil)))
 
-(defun ConTeXt-section-level (name)
+(defun ConTeXt-numbered-section-level (name)
   "Return the level of the section NAME."
-  (let ((entry (TeX-member name ConTeXt-section-list
+  (let ((entry (TeX-member name ConTeXt-numbered-section-list
                           (function (lambda (a b) (equal a (nth 0 b)))))))
+    (if entry
+        (nth 1 entry)
+      nil)))
 
+(defun ConTeXt-unnumbered-section-level (name)
+  "Return the level of the section NAME."
+  (let ((entry (TeX-member name ConTeXt-numbered-section-list
+                           (function (lambda (a b) (equal a (nth 0 b)))))))
     (if entry
        (nth 1 entry)
       nil)))
@@ -379,8 +401,53 @@
 
 ;;; Section Hooks.
 
-(defcustom ConTeXt-section-hook
-  '(ConTeXt-section-heading
+(defcustom ConTeXt-numbered-section-hook
+  '(ConTeXt-numbered-section-heading
+    ConTeXt-section-title
+    ConTeXt-section-ref
+    ConTeXt-section-section)
+  "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 `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).
+
+The following standard hook exist -
+
+ConTeXt-section-heading: Query the user about the name of the
+sectioning command.  Modifies `level' and `name'.
+
+ConTeXt-section-title: Query the user about the title of the
+section.  Modifies `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-ref: Insert a reference for this section command.
+
+To get a full featured `ConTeXt-section' command, insert
+
+ (setq ConTeXt-numbered-section-hook
+                        '(ConTeXt-numbered-section-heading
+                                ConTeXt-section-title
+                                ConTeXt-section-section
+                                ConTeXt-section-ref))
+
+in your .emacs file."
+  :group 'ConTeXt-macro
+  :type 'hook
+  :options
+  '(ConTeXt-numbered-section-heading
+    ConTeXt-section-title
+    ConTeXt-section-ref
+    ConTeXt-section-section))
+
+(defcustom ConTeXt-unnumbered-section-hook
+  '(ConTeXt-unnumbered-section-heading
     ConTeXt-section-title
     ConTeXt-section-ref
     ConTeXt-section-section)
@@ -409,8 +476,8 @@
 
 To get a full featured `ConTeXt-section' command, insert
 
- (setq ConTeXt-section-hook
-                        '(ConTeXt-section-heading
+ (setq ConTeXt-unnumbered-section-hook
+                        '(ConTeXt-unnumbered-section-heading
                                 ConTeXt-section-title
                                 ConTeXt-section-section
                                 ConTeXt-section-ref))
@@ -419,18 +486,30 @@
   :group 'ConTeXt-macro
   :type 'hook
   :options
-  '(ConTeXt-section-heading
+  '(ConTeXt-unnumbered-section-heading
     ConTeXt-section-title
     ConTeXt-section-ref
     ConTeXt-section-section))
 
-(defun ConTeXt-section-heading ()
+(defun ConTeXt-numbered-section-heading ()
   "Hook to prompt for ConTeXt section name.
-Insert this hook into `ConTeXt-section-hook' to allow the user to change
+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 ") ")
-                ConTeXt-section-list
+                ConTeXt-numbered-section-list
+                nil nil nil)))
+    ;; Update name
+    (if (not (zerop (length string)))
+       (setq 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 ") ")
+                ConTeXt-unnumbered-section-list
                 nil nil nil)))
     ;; Update name
     (if (not (zerop (length string)))
@@ -438,7 +517,7 @@
 
 (defun ConTeXt-section-title ()
   "Hook to prompt for ConTeXt section title.
-Insert this hook into `ConTeXt-section-hook' to allow the user to change
+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 (read-string "What title: ")))
 
@@ -912,7 +991,8 @@
    "[][]\\|"  ; display math delimitors (is this applicable to ConTeXt??)
    (ConTeXt-environment-start-name) "\\|"
    (ConTeXt-environment-stop-name) "\\|"
-   (mapconcat 'car ConTeXt-section-list "\\b\\|") "\\b\\|"
+   (mapconcat 'car ConTeXt-numbered-section-list "\\b\\|") "\\b\\|"
+   (mapconcat 'car ConTeXt-unnumbered-section-list "\\b\\|") "\\b\\|"
    (mapconcat 'identity ConTeXt-extra-paragraph-commands "\\b\\|")
    "\\b\\|"
    (mapconcat 'identity ConTeXt-item-list "\\b\\|") "\\b\\)"))
@@ -936,7 +1016,8 @@
    (regexp-quote TeX-esc)
    "\\("
    (mapconcat 'ConTeXt-environment-full-start-name ConTeXt-section-block-list 
"\\|") "\\|"
-   (mapconcat 'car ConTeXt-section-list "\\|")
+   (mapconcat 'car ConTeXt-numbered-section-list "\\|")
+   (mapconcat 'car ConTeXt-unnumbered-section-list "\\|")
    "\\)\\b"
    (if TeX-outline-extra
        "\\|"
@@ -1314,7 +1395,8 @@
 
 ;; section menu entries
 
-(defvar ConTeXt-section-menu-name "Section  (C-c C-s)")
+(defvar ConTeXt-numbered-section-menu-name "Numbered section  (C-c C-s)")
+(defvar ConTeXt-unnumbered-section-menu-name "Unnumbered section")
 
 (defun ConTeXt-section-enable-symbol (level)
   "Symbol used to enable section LEVEL in the menu bar."
@@ -1326,17 +1408,29 @@
     (set (ConTeXt-section-enable-symbol level)
         (>= level ConTeXt-largest-level))))
 
-(defun ConTeXt-section-menu (level)
-  "Insert section from menu."
-  (let ((ConTeXt-section-hook (delq 'ConTeXt-section-heading
-                                   (copy-sequence ConTeXt-section-hook))))
+(defun ConTeXt-numbered-section-menu (level)
+  "Insert numbered section from menu."
+  (let ((ConTeXt-numbered-section-hook (delq 'ConTeXt-numbered-section-heading
+                                   (copy-sequence 
ConTeXt-numbered-section-hook))))
+    (ConTeXt-section level)))
+
+(defun ConTeXt-unnumbered-section-menu (level)
+  "Insert unnumbered section from menu."
+  (let ((ConTeXt-unnumbered-section-hook (delq 
'ConTeXt-unnumbered-section-heading
+                                   (copy-sequence 
ConTeXt-unnumbered-section-hook))))
     (ConTeXt-section level)))
 
-(defun ConTeXt-section-menu-entry (entry)
-  "Create an ENTRY for the section menu."
+(defun ConTeXt-numbered-section-menu-entry (entry)
+  "Create an ENTRY for the numbered section menu."
   (let ((enable (ConTeXt-section-enable-symbol (nth 1 entry))))
     (set enable t)
-    (vector (car entry) (list 'ConTeXt-section-menu (nth 1 entry)) enable)))
+    (vector (car entry) (list 'ConTeXt-numbered-section-menu (nth 1 entry)) 
enable)))
+
+(defun ConTeXt-unnumbered-section-menu-entry (entry)
+  "Create an ENTRY for the unnumbered section menu."
+  (let ((enable (ConTeXt-section-enable-symbol (nth 1 entry))))
+    (set enable t)
+    (vector (car entry) (list 'ConTeXt-unnumbered-section-menu (nth 1 entry)) 
enable)))
 
 
 ;; etexshow support
@@ -1368,7 +1462,8 @@
    `("ConTeXt"
      (,ConTeXt-project-structure-menu-name)
      (,ConTeXt-section-block-menu-name)
-     (,ConTeXt-section-menu-name)
+     (,ConTeXt-numbered-section-menu-name)
+     (,ConTeXt-unnumbered-section-menu-name)
      ["Add Table of Contents to Emacs Menu" (imenu-add-to-menubar "TOC") t]
      "-"
      ["Macro ..." TeX-insert-macro
@@ -1467,10 +1562,14 @@
                           (mapcar 'ConTeXt-section-block-menu-entry
                                   ConTeXt-section-block-list)))
        (message "Updating section menu...")
-       (easy-menu-change '("ConTeXt") ConTeXt-section-menu-name
+       (easy-menu-change '("ConTeXt") ConTeXt-numbered-section-menu-name
+                         (LaTeX-split-long-menu
+                          (mapcar 'ConTeXt-numbered-section-menu-entry
+                                  ConTeXt-numbered-section-list)))
+       (easy-menu-change '("ConTeXt") ConTeXt-unnumbered-section-menu-name
                          (LaTeX-split-long-menu
-                          (mapcar 'ConTeXt-section-menu-entry
-                                  ConTeXt-section-list)))
+                          (mapcar 'ConTeXt-unnumbered-section-menu-entry
+                                  ConTeXt-unnumbered-section-list)))
        (message "Updating...done")
        (and menu (easy-menu-return-item ConTeXt-mode-menu menu))
        )))
@@ -1481,7 +1580,7 @@
   "Command line option for texexec to use nonstopmode.")
 
 (defun ConTeXt-expand-options ()
-  "Expand options for texexec command."
+  "Expand options for context command."
   (concat
    (let ((engine (eval (nth 4 (assq TeX-engine (TeX-engine-alist))))))
      (when engine
@@ -1508,6 +1607,8 @@
     ConTeXt-other-macro-list
     ConTeXt-project-structure-list
     ConTeXt-section-block-list
+    ConTeXt-numbered-section-list
+    ConTeXt-unnumbered-section-list
     ConTeXt-section-list
     ConTeXt-text
     ConTeXt-item-list
@@ -1651,7 +1752,7 @@
 
 Entering `context-mode' calls the value of `text-mode-hook',
 then the value of `TeX-mode-hook', and then the value
-of context-mode-hook."
+of ConTeXt-mode-hook."
   (interactive)
   (context-guess-current-interface)
   (require (intern (concat "context-" ConTeXt-current-interface)))



reply via email to

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