auctex-diffs
[Top][All Lists]
Advanced

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

[AUCTeX-diffs] GNU AUCTeX branch, master, updated. 8f7c39979d8c317d51ee5


From: Tassilo Horn
Subject: [AUCTeX-diffs] GNU AUCTeX branch, master, updated. 8f7c39979d8c317d51ee565d9d1efd0ad0ebb178
Date: Fri, 21 Nov 2014 13:55:07 +0000

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, master has been updated
       via  8f7c39979d8c317d51ee565d9d1efd0ad0ebb178 (commit)
      from  a3f4cac866bce4784858cc1a2e8e3661576445f4 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 8f7c39979d8c317d51ee565d9d1efd0ad0ebb178
Author: Tassilo Horn <address@hidden>
Date:   Fri Nov 21 14:54:21 2014 +0100

    Implement LaTeX-command-section.
    
    * style/book.el ("book"): Set LaTeX-largest-level to part instead
    of chapter.
    
    * tex-buf.el (LaTeX-command-section-level): New variable.
    (LaTeX-command-section-level): New function.
    (LaTeX-command-section-change-level, LaTeX-command-section): New
    commands.
    
    * latex.el (LaTeX-mode-map): Bind C-c C-z to LaTeX-command-section
    and C-c M-z to LaTeX-command-section-change-level.

diff --git a/ChangeLog b/ChangeLog
index 59a020f..eb00e61 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,16 @@
 2014-11-21  Tassilo Horn  <address@hidden>
 
+       * style/book.el ("book"): Set LaTeX-largest-level to part instead
+       of chapter.
+
+       * tex-buf.el (LaTeX-command-section-level): New variable.
+       (LaTeX-command-section-level): New function.
+       (LaTeX-command-section-change-level, LaTeX-command-section): New
+       commands.
+
+       * latex.el (LaTeX-mode-map): Bind C-c C-z to LaTeX-command-section
+       and C-c M-z to LaTeX-command-section-change-level.
+
        * tex.el (TeX-evince-sync-view): Use line/col information from the
        TeX-region buffer if the View command is made on a region.
 
diff --git a/latex.el b/latex.el
index 9e33885..80d2761 100644
--- a/latex.el
+++ b/latex.el
@@ -5248,6 +5248,9 @@ environmens."
     (define-key map "\C-c\C-q\C-s" 'LaTeX-fill-section)
     (define-key map "\C-c\C-q\C-e" 'LaTeX-fill-environment)
 
+    (define-key map "\C-c\C-z" 'LaTeX-command-section)
+    (define-key map "\C-c\M-z" 'LaTeX-command-section-change-level)
+
     (define-key map "\C-c."    'LaTeX-mark-environment) ;*** Dubious
     (define-key map "\C-c*"    'LaTeX-mark-section) ;*** Dubious
 
diff --git a/style/book.el b/style/book.el
index cbc9813..c9571cb 100644
--- a/style/book.el
+++ b/style/book.el
@@ -11,8 +11,8 @@
 
 (TeX-add-style-hook
  "book"
- (lambda () 
-   (LaTeX-largest-level-set "chapter")
+ (lambda ()
+   (LaTeX-largest-level-set "part")
    (LaTeX-add-counters "part" "chapter" "section" "subsection" "subsubsection"
                       "paragraph" "subparagraph" "figure" "table")
    (LaTeX-add-pagestyles "headings" "myheadings"))
diff --git a/tex-buf.el b/tex-buf.el
index 27a4b5c..2623023 100644
--- a/tex-buf.el
+++ b/tex-buf.el
@@ -1525,6 +1525,72 @@ the directory."
   :group 'TeX-command
   :type 'string)
 
+(defvar LaTeX-command-section-level nil
+  "The section level used for `LaTeX-command-section'.
+Will be initialized to `LaTeX-largest-level' buffer-locally.")
+(make-variable-buffer-local 'LaTeX-command-section-level)
+
+(defun LaTeX-command-section-level ()
+  "Return the value of `LaTeX-command-section-level'.
+Initialize it to `LaTeX-largest-level' if needed."
+  (unless LaTeX-command-section-level
+    (setq LaTeX-command-section-level LaTeX-largest-level))
+  LaTeX-command-section-level)
+
+(defun LaTeX-command-section-change-level (arg)
+  "Change `LaTeX-command-section-level' by ARG.
+`LaTeX-command-section-level' is the sectioning level used to
+determine the current section by `LaTeX-command-section'.  The
+levels are defined by `LaTeX-section-list'."
+  (interactive "p")
+  (let ((old-level (car (rassoc (list (LaTeX-command-section-level))
+                               LaTeX-section-list))))
+    (setq LaTeX-command-section-level (+ LaTeX-command-section-level arg))
+    (cond
+     ((> LaTeX-command-section-level 6)
+      (setq LaTeX-command-section-level 6)
+      (message "Cannot shrink LaTeX-command-section-level below 
subparagraph."))
+     ((< LaTeX-command-section-level 0)
+      (setq LaTeX-command-section-level 0)
+      (message "Cannot enlarge LaTeX-command-section-level above part."))
+     (t (message "Changed level from %s to %s."
+                old-level (car (rassoc (list LaTeX-command-section-level)
+                                       LaTeX-section-list)))))))
+
+(defun LaTeX-command-section (&optional override-confirm)
+  "Run a command on the current section.
+
+What makes the current section is defined by
+`LaTeX-command-section-level' which can be enlarged or shrunken
+with `LaTeX-command-section-change-level'.
+
+Query the user for a command to run on the temporary file
+specified by the variable `TeX-region'.  The region file will be
+recreated from current section.
+
+If a prefix argument OVERRIDE-CONFIRM is given, confirmation will
+depend on it being positive instead of the entry in
+`TeX-command-list'."
+  (interactive "P")
+  (let* ((case-fold-search t)
+        (rx (concat "\\\\" (regexp-opt
+                            (mapcar
+                             (lambda (level)
+                               (car (rassoc (list level) LaTeX-section-list)))
+                             (let (r)
+                               (dotimes (i (1+ (LaTeX-command-section-level)))
+                                 (push i r))
+                               r)))
+                    "{"))
+        (TeX-command-region-begin (save-excursion
+                                    (re-search-backward rx nil t)
+                                    (point)))
+        (TeX-command-region-end (save-excursion
+                                  (re-search-forward rx nil t)
+                                  (forward-line 0)
+                                  (point))))
+    (TeX-command-region override-confirm)))
+
 ;;; Parsing
 
 ;;; - Global Parser Variables

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

Summary of changes:
 ChangeLog     |   11 +++++++++
 latex.el      |    3 ++
 style/book.el |    4 +-
 tex-buf.el    |   66 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 82 insertions(+), 2 deletions(-)


hooks/post-receive
-- 
GNU AUCTeX



reply via email to

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