emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[elpa] elpa d120a27 22/23: Merge branch 'master' into elpa


From: Tassilo Horn
Subject: [elpa] elpa d120a27 22/23: Merge branch 'master' into elpa
Date: Wed, 30 Mar 2016 19:08:03 +0000

branch: elpa
commit d120a27a5e445c3262023d091f774c10bbebf313
Merge: df2c08f 00430f2
Author: Tassilo Horn <address@hidden>
Commit: Tassilo Horn <address@hidden>

    Merge branch 'master' into elpa
---
 Makefile.in       |    2 +-
 doc/changes.texi  |    5 +
 latex.el          |    4 +-
 style/currvita.el |    2 +-
 style/enumitem.el |   24 +-----
 style/environ.el  |   12 +++-
 style/splitidx.el |    4 +-
 style/tikz.el     |  231 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 tex-bar.el        |   12 +--
 tex-buf.el        |   14 ++-
 10 files changed, 270 insertions(+), 40 deletions(-)

diff --git a/Makefile.in b/Makefile.in
index 471ff21..b390c66 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -154,7 +154,7 @@ STYLESRC = style/prosper.el \
           style/fontenc.el   style/Alegreya.el  style/gloss-italian.el \
           style/newfloat.el  style/subcaption.el style/AlegreyaSans.el \
           style/hologo.el    style/theorem.el   style/ntheorem.el \
-          style/splitidx.el
+          style/splitidx.el  style/tikz.el
 
 STYLEELC = $(STYLESRC:.el=.elc)
 
diff --git a/doc/changes.texi b/doc/changes.texi
index 9d39db2..9d36f09 100644
--- a/doc/changes.texi
+++ b/doc/changes.texi
@@ -12,6 +12,11 @@
 
 @itemize @bullet
 @item
address@hidden now has limited support for the TikZ package.  For the moment,
+this includes some basic support for prompting the user of arguments to
+the @samp{\draw} macro.
+
address@hidden
 When inserting a new float, @AUCTeX{} will now prompt for a
 short-caption if the length of the caption provided is greater than a
 certain size.  This size is controlled via a new user option
diff --git a/latex.el b/latex.el
index c0b0baf..9c2ccb5 100644
--- a/latex.el
+++ b/latex.el
@@ -720,7 +720,9 @@ environment just inserted, the buffer position just before
     (if active-mark
        (progn
          (or (assoc environment LaTeX-indent-environment-list)
-             (LaTeX-fill-region content-start (line-beginning-position 2)))
+             (if auto-fill-function
+                 ;; Fill the region only when `auto-fill-mode' is active.
+                 (LaTeX-fill-region content-start (line-beginning-position 
2))))
          (set-mark content-start))
       (indent-according-to-mode))
     (save-excursion (beginning-of-line 2) (indent-according-to-mode))
diff --git a/style/currvita.el b/style/currvita.el
index 3da2738..a008753 100644
--- a/style/currvita.el
+++ b/style/currvita.el
@@ -56,7 +56,7 @@
   ;; The inserted \item may have outdented the first line to the
   ;; right.  Fill it, if appropriate.
   (when (and (not (looking-at "$"))
-            (not (assoc environment LaTeX-indent-environment-list))
+            (not (assoc env LaTeX-indent-environment-list))
             (> (- (line-end-position) (line-beginning-position))
                (current-fill-column)))
     (LaTeX-fill-paragraph nil)))
diff --git a/style/enumitem.el b/style/enumitem.el
index 87249bc..c81cd96 100644
--- a/style/enumitem.el
+++ b/style/enumitem.el
@@ -209,7 +209,7 @@ key-val and the first item."
   ;; The inserted \item may have outdented the first line to the
   ;; right.  Fill it, if appropriate.
   (when (and (not (looking-at "$"))
-            (not (assoc environment LaTeX-indent-environment-list))
+            (not (assoc env LaTeX-indent-environment-list))
             (> (- (line-end-position) (line-beginning-position))
                (current-fill-column)))
     (LaTeX-fill-paragraph nil)))
@@ -218,13 +218,7 @@ key-val and the first item."
   "Ask for new type (value) for the \"align\" key and add it to
 `LaTeX-enumitem-key-val-options-local'."
   (LaTeX-enumitem-update-key-val-options)
-  (let* ((key "align")
-        (val (TeX-read-string "Alignment: "))
-        (val-match (cdr (assoc key LaTeX-enumitem-key-val-options-local)))
-        (temp (copy-alist LaTeX-enumitem-key-val-options-local))
-        (opts (assq-delete-all (car (assoc key temp)) temp)))
-    (pushnew (list key (delete-dups (apply 'append (list val) val-match)))
-            opts :test #'equal)
+  (let ((val (TeX-read-string "Alignment: ")))
     (TeX-argument-insert val optional)
     (LaTeX-add-enumitem-SetLabelAligns val)))
 
@@ -237,7 +231,6 @@ key-val and the first item."
                                   LaTeX-enumitem-key-val-options-local 
"Replacement")))
     (TeX-argument-insert key     optional)
     (TeX-argument-insert replace optional)
-    (add-to-list 'LaTeX-enumitem-key-val-options-local (list key))
     (LaTeX-add-enumitem-SetEnumitemKeys key)))
 
 ;; In `LaTeX-enumitem-SetEnumitemValue-regexp', we match (0 1 2).
@@ -250,17 +243,8 @@ key-val and the first item."
   "Ask for a new value added to an existing key incl. the final
 replacement of the value."
   (LaTeX-enumitem-update-key-val-options)
-  (let* ((key (completing-read  "Key: " LaTeX-enumitem-key-val-options-local))
-        (val (TeX-read-string "String value: "))
-        ;; (key-match (car (assoc key LaTeX-enumitem-key-val-options-local)))
-        (val-match (cdr (assoc key LaTeX-enumitem-key-val-options-local)))
-        (temp (copy-alist LaTeX-enumitem-key-val-options-local))
-        (opts (assq-delete-all (car (assoc key temp)) temp)))
-    (if val-match
-       (pushnew (list key (delete-dups (apply 'append (list val) val-match)))
-                opts :test #'equal)
-      (pushnew (list key (list val)) opts :test #'equal))
-    (setq LaTeX-enumitem-key-val-options-local (copy-alist opts))
+  (let ((key (completing-read  "Key: " LaTeX-enumitem-key-val-options-local))
+       (val (TeX-read-string "String value: ")))
     (TeX-argument-insert key optional)
     (TeX-argument-insert val optional)
     (LaTeX-add-enumitem-SetEnumitemValues
diff --git a/style/environ.el b/style/environ.el
index bac82fc..c6b34cc 100644
--- a/style/environ.el
+++ b/style/environ.el
@@ -1,6 +1,6 @@
 ;;; environ.el --- AUCTeX style for `environ.sty' version v0.3
 
-;; Copyright (C) 2015 Free Software Foundation, Inc.
+;; Copyright (C) 2015, 2016 Free Software Foundation, Inc.
 
 ;; Author: Arash Esbati <esbati'at'gmx.de>
 ;; Maintainer: address@hidden
@@ -118,7 +118,15 @@ from `environ.sty'.")
     '("BODY")
 
     ;; Define another macro instead of \BODY
-    '("environbodyname" TeX-arg-define-macro)))
+    '("environbodyname" TeX-arg-define-macro))
+
+   ;; Fontification
+   (when (and (featurep 'font-latex)
+             (eq TeX-install-font-lock 'font-latex-setup))
+     (font-latex-add-keywords '(("NewEnviron"      "{[[{[")
+                               ("RenewEnviron"    "{[[{[")
+                               ("environbodyname" "|{\\"))
+                             'function)))
   LaTeX-dialect)
 
 (defvar LaTeX-environ-package-options nil
diff --git a/style/splitidx.el b/style/splitidx.el
index e299b5a..0c3ddf0 100644
--- a/style/splitidx.el
+++ b/style/splitidx.el
@@ -126,8 +126,8 @@
                     1 LaTeX-auto-index-entry))
       ;; Cater for completion
       (add-to-list 'TeX-complete-list
-                  `(,(concat "\\\\" elt "{\\([^{}\n\r]*\\)"
-                    1 LaTeX-index-entry-list "}"))) )))
+                  `(,(concat "\\\\" elt "{\\([^{}\n\r]*\\)")
+                    1 LaTeX-index-entry-list "}")) )))
 
 (add-hook 'TeX-auto-prepare-hook #'LaTeX-splitidx-auto-prepare t)
 (add-hook 'TeX-auto-cleanup-hook #'LaTeX-splitidx-auto-cleanup t)
diff --git a/style/tikz.el b/style/tikz.el
new file mode 100644
index 0000000..be93110
--- /dev/null
+++ b/style/tikz.el
@@ -0,0 +1,231 @@
+;;; tikz.el --- AUCTeX style for `tikz.sty'
+
+;; Copyright (C) 2016 Free Software Foundation, Inc.
+
+;; Author: Matthew Leach <address@hidden>
+;; Maintainer: address@hidden
+;; Created: 2016-22-03
+;; Keywords: tex tikz
+
+;; This file is part of AUCTeX.
+
+;; AUCTeX is free software; you can redistribute it and/or modify it
+;; under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 3, or (at your option)
+;; any later version.
+
+;; AUCTeX is distributed in the hope that it will be useful, but
+;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+;; General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with AUCTeX; see the file COPYING.  If not, write to the Free
+;; Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+;; 02110-1301, USA.
+
+;;; Commentary:
+
+;; This file adds some support for `tikz.sty'
+
+;;; Code:
+
+(defun TeX-TikZ-get-opt-arg-string (arg &optional open close)
+  "Return a string for optional arguments.
+If ARG is nil or \"\", return \"\".  Otherwise return \"OPEN ARG
+CLOSE\". If OPEN or CLOSE are nil, set them to `LaTeX-optop' and
+`LaTeX-optcl' respectively."
+  (unless (or open close)
+    (setq open LaTeX-optop)
+    (setq close LaTeX-optcl))
+  (if (and arg (> (length arg) 0))
+      (concat open arg close)
+    ""))
+
+(defun TeX-TikZ-arg-rect-point (_ignored)
+  "Prompt the user for a point on the Cartesian plane.
+Ask the user for an X and Y coordinate, and return the string
+\"(X,Y)\"."
+  (let ((x (TeX-read-string (TeX-argument-prompt nil nil "X-coordinate")))
+        (y (TeX-read-string (TeX-argument-prompt nil nil "Y-coordinate"))))
+   (concat " (" x ", " y") ")))
+
+(defun TeX-TikZ-arg-polar-point (_ignored)
+  "Prompt the user for a point on the polar plane.
+Ask the user for r and theta values, and return the string
+\"(THETA:R)\"."
+  (let ((r (TeX-read-string (TeX-argument-prompt nil nil "R")))
+        (theta (TeX-read-string (TeX-argument-prompt nil nil "Theta"))))
+   (concat " (" theta ":" r ") ")))
+
+(defun TeX-TikZ-arg-options (optional)
+  "Prompt the user for options to a TikZ macro.
+If OPTIONAL is non-nil, always return `LaTeX-optop' and
+`LaTeX-optcl', even if the user doesn't provide any input."
+  (let ((options (TeX-read-string (TeX-argument-prompt optional nil "Options" 
))))
+    (if optional
+        (TeX-TikZ-get-opt-arg-string options)
+      (concat LaTeX-optop options LaTeX-optcl))))
+
+(defun TeX-TikZ-arg-name (optional)
+  "Prompt the user for a TikZ name.
+If OPTIONAL is non-nil, always return \"()\", even if the user
+doesn't provide any input."
+  (let ((name (TeX-read-string (TeX-argument-prompt optional nil "Name" ))))
+    (if optional
+        (TeX-TikZ-get-opt-arg-string name "(" ")")
+      (concat "(" name ")"))))
+
+(defun TeX-TikZ-arg-label (optional)
+  "Prompt the user for TikZ label.
+If OPTIONAL is non-nil always return `TeX-grop' and `TeX-grcl',
+even if the user doesn't provide any input."
+  (let ((label (TeX-read-string (TeX-argument-prompt optional nil "Label" ))))
+    (if optional
+        (TeX-TikZ-get-opt-arg-string label TeX-grop TeX-grcl)
+      (concat TeX-grop label TeX-grcl))))
+
+(defun TeX-TikZ-arg-node (_ignored)
+  "Prompt the user for the deatils of a node.
+Ask the user for the name and text for a node and return the
+string \"node[OPTIONS](NAME){TEXT}\"."
+  (let ((options (TeX-TikZ-arg-options t))
+        (name (TeX-TikZ-arg-name t))
+        (label (TeX-TikZ-arg-label nil)))
+    (concat "node" options name label " ")))
+
+(defun TeX-TikZ-get-arg-type (types &optional prompt)
+  "Prompt the user for an argument type.
+TYPES is a list of possible types that the user can specify.  If
+PROMPT is non-nil use that prompt instead."
+  (let ((completion-ignore-case t)
+        (prompt (if prompt
+                    prompt
+                  "Next argument type (RET to finish): ")))
+    (completing-read prompt types nil t)))
+
+(defun TeX-TikZ-single-macro-arg (function-alist &optional prompt)
+  "Prompt the user for a single argument to compose a TikZ macro.
+FUNCTION-ALIST is a mapping of argument-types to functions.  The
+user is prompted for the argument type, the chosen function is
+then called and the value returned.  PROMPT is used as the prompt
+for the argument type."
+  (let* ((argument-types (mapcar 'car function-alist))
+         (argument-type (TeX-TikZ-get-arg-type argument-types prompt)))
+    (funcall
+     (cadr (assoc argument-type function-alist))
+     argument-type)))
+
+
+(defun TeX-TikZ-macro-arg (function-alist)
+  "Prompt the user for arguments to compose a TikZ macro.
+FUNCTION-ALIST is a mapping of argument-types to functions.  The
+user is repeatedly prompted for the next argument-type; they can
+choose form the cars in FUNCTION-ALIST and the appropriate
+function is then called.  If the user enters \"\", then the macro
+is finished."
+  (let* ((options (TeX-TikZ-arg-options t))
+         ;; For the iterative version, we need to add "" to the
+         ;; function-alist, allowing the user to end the macro.
+         (function-alist-iterative `(,@function-alist ("" identity)))
+         (string-to-insert (TeX-TikZ-single-macro-arg 
function-alist-iterative)))
+
+    ;; Insert the macro options.
+    (insert options " ")
+
+    ;; Iteratively prompt the user for TikZ's arguments until "" is
+    ;; returned.
+    (while (not (string= string-to-insert ""))
+      (insert string-to-insert)
+      (setq string-to-insert
+            (TeX-TikZ-single-macro-arg function-alist-iterative)))
+
+    ;; Finish the macro.
+    (insert ";")))
+
+(defcustom TeX-TikZ-point-name-regexp
+  "(\\([A-Za-z0-9]+\\))"
+  "A regexp that matches TikZ names."
+  :type 'regexp
+  :group 'auctex-tikz)
+
+(defun TeX-TikZ-find-named-points ()
+  "Find TiKZ named points in current enviroment.
+Begin by finding the span of the current TikZ enviroment and then
+searching within that span to find all named-points and return
+them as a list of strings, dropping the '()'."
+  (let* ((env-end (save-excursion
+                    (LaTeX-find-matching-end)
+                     (point)))
+         (matches ()))
+    ;; TODO: Handle cases where we are in a nested environment, \scope
+    ;; for example.
+    (save-excursion
+      (LaTeX-find-matching-begin)
+      (save-match-data
+        (while (re-search-forward TeX-TikZ-point-name-regexp env-end t)
+          (add-to-list 'matches (match-string 1)))))
+    matches))
+
+(defun TeX-TikZ-arg-named-point (_ignored)
+  "Prompt the user for the name of a previous named-point."
+  (let ((point-name (completing-read "Point name: "
+                                     (TeX-TikZ-find-named-points))))
+    (concat " (" point-name ") ")))
+
+(defconst TeX-TikZ-point-function-map
+  '(("Rect Point" TeX-TikZ-arg-rect-point)
+    ("Polar Point" TeX-TikZ-arg-polar-point)
+    ("Named Point" TeX-TikZ-arg-named-point))
+  "An alist of point specification types and their functions." )
+
+(defconst TeX-TikZ-path-connector-function-map
+  (let ((connectors '("--" "|-" "-|")))
+    (apply 'append (mapcar
+                     (lambda (connector)
+                       `((,connector identity)
+                         (,(concat connector " +") identity)
+                         (,(concat connector " ++") identity)))
+                     connectors)))
+  "An alist of path connectors.
+A set of base connectors along with variants that have \" +\" and
+\" ++\" appended to them, mapping to the identity function.")
+
+(defconst TeX-TikZ-draw-arg-function-map
+  `(,@TeX-TikZ-point-function-map
+    ,@TeX-TikZ-path-connector-function-map
+    ("Node" TeX-TikZ-arg-node))
+  "An alist of argument names and functoins for TikZ's \draw.")
+
+(defun TeX-TikZ-draw-arg (_ignored)
+  "Prompt the user for the arguments to a TikZ draw macro."
+  (TeX-TikZ-macro-arg TeX-TikZ-draw-arg-function-map))
+
+(defun TeX-TikZ-coordinate-arg (_ignored)
+  "Prompt the user for the arguments to a TikZ coordinate macro."
+  (let ((options (TeX-TikZ-arg-options t))
+        (name (TeX-TikZ-arg-name nil))
+        (point (TeX-TikZ-single-macro-arg TeX-TikZ-point-function-map
+                                          "Coordinate point type: ")))
+    (insert options " " name " at" point ";")))
+
+(defun TeX-TikZ-node-arg (_ignored)
+  "Prompt the user for the arguments to a TikZ node macro."
+  (let ((options (TeX-TikZ-arg-options t))
+        (name (TeX-TikZ-arg-name nil))
+        (point (TeX-TikZ-single-macro-arg TeX-TikZ-point-function-map
+                                          "Node point type: "))
+        (label (TeX-TikZ-arg-label nil)))
+    (insert options " " name  " at" point label ";")))
+
+(TeX-add-style-hook
+ "tikz"
+ (lambda ()
+   (TeX-add-symbols
+    '("draw" (TeX-TikZ-draw-arg))
+    '("coordinate" (TeX-TikZ-coordinate-arg))
+    '("node" (TeX-TikZ-node-arg)))
+   (LaTeX-add-environments
+    '("tikzpicture"))))
+
+;;; tikz.el ends here
diff --git a/tex-bar.el b/tex-bar.el
index f3cbaf1..59b9158 100644
--- a/tex-bar.el
+++ b/tex-bar.el
@@ -176,10 +176,8 @@ the argument BUTTON-ALIST in function 
`toolbarx-install-toolbar'."
                    (TeX-bar-help-from-command-list "PDFTeX")))
     (next-error :image "error"
                :command TeX-next-error
-               :enable (plist-get TeX-error-report-switches
-                                  (intern (TeX-master-file)))
-               :visible (plist-get TeX-error-report-switches
-                                   (intern (TeX-master-file))))
+               :enable (TeX-error-report-has-errors-p)
+               :visible (TeX-error-report-has-errors-p))
     (view :image (lambda nil (if TeX-PDF-mode "viewpdf" "viewdvi"))
          :command (TeX-command "View" 'TeX-master-file -1)
          :help (lambda (&rest ignored)
@@ -322,10 +320,8 @@ the argument BUTTON-ALIST in function 
`toolbarx-install-toolbar'."
                      (TeX-bar-help-from-command-list "PDFLaTeX")))
     (next-error :image "error"
                :command TeX-next-error
-               :enable (plist-get TeX-error-report-switches
-                                  (intern (TeX-master-file)))
-               :visible (plist-get TeX-error-report-switches
-                                   (intern (TeX-master-file))))
+               :enable (TeX-error-report-has-errors-p)
+               :visible (TeX-error-report-has-errors-p))
     (view :image (lambda nil (if TeX-PDF-mode "viewpdf" "viewdvi"))
          :command (TeX-command "View" 'TeX-master-file -1)
          :help (lambda (&rest ignored)
diff --git a/tex-buf.el b/tex-buf.el
index dca6614..0d459cf 100644
--- a/tex-buf.el
+++ b/tex-buf.el
@@ -1014,9 +1014,13 @@ Return the new process."
 
 (defvar TeX-error-report-switches nil
   "Reports presence of errors after `TeX-run-TeX'.
-To test whether the current buffer has an compile error from last
+To test whether the current buffer has a compile error from last
 run of `TeX-run-TeX', use
-  (plist-get TeX-error-report-switches (intern (TeX-master-file)))")
+  (TeX-error-report-has-errors-p)")
+
+(defun TeX-error-report-has-errors-p ()
+  "Return non-nil if current buffer has compile errors from last TeX run."
+  (plist-get TeX-error-report-switches (intern (TeX-master-file))))
 
 (defun TeX-run-TeX (name command file)
   "Create a process for NAME using COMMAND to format FILE with TeX."
@@ -1551,7 +1555,7 @@ Rerun to get mark in right position\\." nil t)
                 (md5 (current-buffer)))))
         (push (cons idx-file t) LaTeX-idx-changed-alist)))
 
-  (unless TeX-error-list
+  (unless (TeX-error-report-has-errors-p)
     (run-hook-with-args 'TeX-after-compilation-finished-functions
                        (with-current-buffer TeX-command-buffer
                          (expand-file-name
@@ -1657,7 +1661,7 @@ variable is nil."
        (with-current-buffer TeX-command-buffer
          (unless
              (or
-              (plist-get TeX-error-report-switches (intern (TeX-master-file)))
+              (TeX-error-report-has-errors-p)
               (null TeX-command-sequence-command))
            (TeX-command-sequence TeX-command-sequence-command nil
                                  TeX-command-sequence-file-function))))))
@@ -1763,7 +1767,7 @@ command."
        ;; Remove line breaks at columns 79 and 80
        (while (> (point) pt)
          (end-of-line 0)
-         (when (and (memql (- (point) (line-beginning-position)) '(79 80))
+         (when (and (memq (- (point) (line-beginning-position)) '(79 80))
                     ;; Heuristic: Don't delete the linebreak if the next line
                     ;; is empty or starts with an opening parenthesis, or if
                     ;; point is located after a period and in the next line no



reply via email to

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