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. 2a642a45814b57243a6c7


From: Arash Esbati
Subject: [AUCTeX-diffs] GNU AUCTeX branch, master, updated. 2a642a45814b57243a6c78aa876211175afc992e
Date: Sat, 20 Apr 2019 16:21:22 -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, master has been updated
       via  2a642a45814b57243a6c78aa876211175afc992e (commit)
      from  d4660ddd110be7e5cd3a8dd9f6557f2c14350b0f (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 2a642a45814b57243a6c78aa876211175afc992e
Author: Arash Esbati <address@hidden>
Date:   Sat Apr 20 22:19:33 2019 +0200

    Add support for ChangeLog entries for LaTeX files
    
    * tex.el (TeX-current-defun-name): New function returning the name
    of current sectioning command when `C-x 4 a' is invoked.
    
    * latex.el (LaTeX-common-initialization): Set a local version
    `add-log-current-defun-function' to `TeX-current-defun-name'.

diff --git a/latex.el b/latex.el
index 898eec8..6a96cb4 100644
--- a/latex.el
+++ b/latex.el
@@ -1,6 +1,6 @@
 ;;; latex.el --- Support for LaTeX documents.
 
-;; Copyright (C) 1991, 1993-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1991, 1993-2019 Free Software Foundation, Inc.
 
 ;; Maintainer: address@hidden
 ;; Keywords: tex
@@ -6516,7 +6516,11 @@ function would return non-nil and `(match-string 1)' 
would return
   ;; emacs 24.4.
   (when (and LaTeX-electric-left-right-brace
             (boundp 'electric-pair-mode))
-    (set (make-local-variable 'electric-pair-mode) nil)))
+    (set (make-local-variable 'electric-pair-mode) nil))
+
+  ;; Initialization of `add-log-current-defun-function':
+  (set (make-local-variable 'add-log-current-defun-function)
+       #'TeX-current-defun-name))
 
 (defun LaTeX-imenu-create-index-function ()
   "Imenu support function for LaTeX."
diff --git a/tex.el b/tex.el
index f469a6c..6c2cbb6 100644
--- a/tex.el
+++ b/tex.el
@@ -1,6 +1,6 @@
 ;;; tex.el --- Support for TeX documents.
 
-;; Copyright (C) 1985-1987, 1991, 1993-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1985-1987, 1991, 1993-2019 Free Software Foundation, Inc.
 
 ;; Maintainer: address@hidden
 ;; Keywords: tex
@@ -6575,6 +6575,57 @@ Used as function for validating a variable's 
`safe-local-variable' property."
           (setq lst (cdr lst)))
         all-strings)))
 
+;; add-log.el: This function is a variation of
+;; `tex-current-defun-name' defined in `tex-mode.el'.  In `latex.el',
+;; the variable `add-log-current-defun-function' is set to this
+;; function.
+(defun TeX-current-defun-name ()
+  "Return the name of the TeX section/paragraph/chapter at point, or nil."
+  (save-excursion
+    (let (s1 e1 s2 e2)
+      ;; If we are now precisely at the beginning of a sectioning
+      ;; command, move forward and make sure `re-search-backward'
+      ;;  finds this one rather than the previous one:
+      (or (eobp) (progn
+                   (when (looking-at-p "\\\\")
+                     (forward-char))
+                   (unless (eolp)
+                     (forward-sexp))))
+      ;; Search backward for sectioning command.  If
+      ;; `LaTeX-section-label' is buffer-local, assume that a style
+      ;; has changed the value and recalculate the string.  Otherwise
+      ;; take the standard one:
+      (when (re-search-backward
+             (if (local-variable-p 'LaTeX-section-label)
+                 (concat (regexp-opt
+                          (remove "part" (mapcar #'car LaTeX-section-label)))
+                         "\\*?")
+               "\\\\\\(sub\\)*\\(section\\|paragraph\\|chapter\\)\\*?")
+             nil t)
+        ;; Skip over the backslash:
+        (setq s1 (1+ (point)))
+        ;; Skip over the sectioning command, incl. the *:
+        (setq e1 (goto-char (match-end 0)))
+        ;; Skip over the optional argument, if any:
+        (when (looking-at-p "[ \t]*\\[")
+          (forward-sexp))
+        ;; Skip over any chars until the mandatory argument:
+        (skip-chars-forward "^{")
+        ;; Remember the points for the mandatory argument:
+        (setq s2 (point))
+        (setq e2 (progn (forward-sexp)
+                        (point)))
+        ;; Now pick the content: For one-line title, return it
+        ;; incl. the closing brace.  For multi-line, return the first
+        ;; line of the mandatory argument incl. ellipsis and a brace;
+        (concat
+         (buffer-substring-no-properties s1 e1)
+         (buffer-substring-no-properties
+          (goto-char s2)
+          (min (line-end-position) e2))
+         (when (> e2 (line-end-position))
+           (concat "..." TeX-grcl)))))))
+
 (provide 'tex)
 
 ;; Local Variables:

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

Summary of changes:
 latex.el |  8 ++++++--
 tex.el   | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 58 insertions(+), 3 deletions(-)


hooks/post-receive
-- 
GNU AUCTeX



reply via email to

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