[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/auctex 8f7c399 30/36: Implement LaTeX-command-section.
From: |
Stefan Monnier |
Subject: |
[elpa] externals/auctex 8f7c399 30/36: Implement LaTeX-command-section. |
Date: |
Fri, 28 Nov 2014 17:25:51 +0000 |
branch: externals/auctex
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.
---
ChangeLog | 11 +++++++++
latex.el | 3 ++
style/book.el | 4 +-
tex-buf.el | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 82 insertions(+), 2 deletions(-)
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
- [elpa] externals/auctex 0cb3759 26/36: Implement inverse/backward search for TeX regions., (continued)
- [elpa] externals/auctex 0cb3759 26/36: Implement inverse/backward search for TeX regions., Stefan Monnier, 2014/11/28
- [elpa] externals/auctex 0bae61a 18/36: Add `ifluatex.el' to Makefile.in, Stefan Monnier, 2014/11/28
- [elpa] externals/auctex daa8a25 20/36: Update windows-package Make rule to new Emacs 24.4 package., Stefan Monnier, 2014/11/28
- [elpa] externals/auctex 622c054 22/36: Document presence of bashisms in some Make rules., Stefan Monnier, 2014/11/28
- [elpa] externals/auctex 904dfef 21/36: Fix structure of the package for Windows., Stefan Monnier, 2014/11/28
- [elpa] externals/auctex 3909e4c 06/36: Several changes suggested by byte-compiler warnings., Stefan Monnier, 2014/11/28
- [elpa] externals/auctex a3f4cac 29/36: Implement forward-search for View command on TeX-region., Stefan Monnier, 2014/11/28
- [elpa] externals/auctex 0c2cfc8 09/36: Replace `read-string' with `TeX-read-string', Stefan Monnier, 2014/11/28
- [elpa] externals/auctex acf1c76 31/36: Document LaTeX-command-section., Stefan Monnier, 2014/11/28
- [elpa] externals/auctex 15edd9b 23/36: Omit f-f hooks and more with TeX-region-create, Stefan Monnier, 2014/11/28
- [elpa] externals/auctex 8f7c399 30/36: Implement LaTeX-command-section.,
Stefan Monnier <=
- [elpa] externals/auctex e4101ed 25/36: Adapt bug intro text for debbugs., Stefan Monnier, 2014/11/28
- [elpa] externals/auctex 7b427a7 34/36: Merge ELPA changes fixing some byte-compile warnings., Stefan Monnier, 2014/11/28
- [elpa] externals/auctex 58bd866 28/36: Fix indentation in LaTeX-env-figure in a corner case., Stefan Monnier, 2014/11/28
- [elpa] externals/auctex e1ec6a0 33/36: Make second argument of LaTeX-label optional., Stefan Monnier, 2014/11/28
- [elpa] externals/auctex 59ccf34 35/36: Check the viewer executable exists before opening it., Stefan Monnier, 2014/11/28
- [elpa] externals/auctex e739b85 32/36: Move preview/ to top-level., Stefan Monnier, 2014/11/28
- [elpa] externals/auctex c390682 36/36: Merge from upstream., Stefan Monnier, 2014/11/28