auctex-devel
[Top][All Lists]
Advanced

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

[AUCTeX-devel] plain TeX mode tool bar


From: Reiner Steib
Subject: [AUCTeX-devel] plain TeX mode tool bar
Date: Wed, 26 Jul 2006 15:11:45 +0200
User-agent: Gnus/5.110006 (No Gnus v0.6) Emacs/22.0.50 (gnu/linux)

Hi,

wouldn't the following trivial copy&paste patch enable the TeX
specific tool bar for plain TeX?  Should I install it (maybe with
`TeX-enable-toolbar' defaulting to nil)?

Disclaimer: I rarely use plain TeX mode so I won't be able to find
non-obvious bugs.

--8<---------------cut here---------------start------------->8---
--- tex-bar.el  25 May 2006 07:50:57 -0000      1.13
+++ tex-bar.el  26 Jul 2006 13:07:14 -0000
@@ -82,6 +82,122 @@
   "Tool bar support in AUCTeX."
   :group 'AUCTeX)
 
+(defcustom TeX-bar-TeX-buttons
+  '(open-file save-buffer cut copy paste undo
+             [separator nil] tex next-error view bibtex)
+  "List of buttons available in `tex-mode'.
+It should be a list in the same format of the BUTTONS parameter
+in function `toolbarx-install-toolbar', often a symbol that
+labels a button or Emacs/XEmacs choice of buttons.
+
+Type `\\[TeX-bar-TeX-buttons]' for a list of available buttons.
+
+Buttons are defined in alists (labels associated to properties
+that define a button).  For a list of variables that hold such
+alists, see variable `TeX-bar-TeX-all-button-alists'."
+  :type '(repeat (choice (symbol :tag "Label")
+                        (vector :args ((symbol :tag "Label in Emacs ")
+                                       (symbol :tag "Label in XEmacs"))
+                                :tag "Emacs/XEmacs choice")
+                        (sexp :tag "General element")))
+  :group 'TeX-tool-bar)
+
+(defun TeX-bar-TeX-buttons ()
+  "Display in a buffer a list of buttons for `tex-bar.el'."
+  (interactive)
+  (let ((assqs-button-alists)
+       (labels))
+    (dolist (m-alist TeX-bar-TeX-all-button-alists)
+      (setq labels nil)
+      (dolist (as (eval m-alist))
+       (setq labels (cons (car as) labels)))
+      (setq assqs-button-alists (cons (cons m-alist (nreverse labels))
+                                      assqs-button-alists)))
+    (setq assqs-button-alists (nreverse assqs-button-alists))
+    ;; displaying results
+    (save-excursion
+      (set-buffer (get-buffer-create "*TeX tool bar buttons*"))
+      (erase-buffer)
+      (insert "Available buttons for TeX mode
+================================")
+      (dolist (i assqs-button-alists)
+       (insert (format "\n\n`%s' provide buttons:\n  " (car i)))
+       (dolist (j (cdr i))
+         (insert (format " %s" j)))
+       (fill-region (point-at-bol) (point-at-eol))))
+    (display-buffer "*TeX tool bar buttons*" t)))
+
+(defgroup TeX-tool-bar-button-definitions nil
+  "Collections of button definitions."
+  :group 'TeX-tool-bar)
+
+(defcustom TeX-bar-TeX-all-button-alists
+  '(TeX-bar-TeX-button-alist
+    toolbarx-default-toolbar-meaning-alist)
+  "List of variables that hold buttons properties.
+Each element should be a symbol bound to list in the format of
+the argument BUTTON-ALIST in function `toolbarx-install-toolbar'."
+  :type '(repeat variable)
+  :group 'TeX-tool-bar-button-definitions)
+
+(defcustom TeX-bar-TeX-button-alist
+  '((tex :image (lambda nil (if TeX-PDF-mode "pdftex" "tex"))
+        :command (progn
+                   (TeX-save-document (TeX-master-file))
+                   (TeX-command "TeX" 'TeX-master-file -1))
+        :help (lambda (&rest ignored)
+                (TeX-bar-help-from-command-list "TeX")))
+    (pdftex :image "pdftex"
+           :command (progn
+                      (TeX-save-document (TeX-master-file))
+                      (TeX-command "PDFTeX" 'TeX-master-file -1))
+           :help (lambda (&rest ignored)
+                   (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))))
+    (view :image (lambda nil (if TeX-PDF-mode "viewpdf" "viewdvi"))
+         :command (TeX-command "View" 'TeX-master-file -1)
+         :help (lambda (&rest ignored)
+                 (TeX-bar-help-from-command-list "View")))
+    (file :image "dvips"
+         :command (TeX-command "File" 'TeX-master-file -1)
+         :help (lambda (&rest ignored)
+                 (TeX-bar-help-from-command-list "File")))
+    (bibtex :image "bibtex"
+           :command (TeX-command "BibTeX" 'TeX-master-file -1)
+           :help (lambda (&rest ignored)
+                   (TeX-bar-help-from-command-list "BibTeX"))))
+  ;; latex-symbols-experimental?
+  "Alist for button definitions in TeX bar.
+Value should le a list where each element is of format (KEY .
+PROPS), where KEY is a symbol that labels the button and PROPS is
+a list of properties of the button.  For a description of the
+format of PROPS, please see documentation of function
+`toolbarx-install-toolbar'.  This custom variable is in the same
+format of the argument MEANING-ALIST in the mentioned function."
+  :type '(alist :key-type symbol :value-type sexp)
+  :group 'TeX-tool-bar-button-definitions)
+
+;;; Installation of the tool bar
+;;;###autoload
+(defun TeX-install-toolbar ()
+  "Install toolbar buttons for TeX mode."
+  (interactive)
+  (require 'toolbar-x)
+  (add-to-list 'toolbarx-image-path
+              (expand-file-name "images" TeX-data-directory))
+  (add-hook 'TeX-PDF-mode-hook 'toolbarx-refresh)
+  (toolbarx-install-toolbar TeX-bar-TeX-buttons
+                           (let ((append-list))
+                             (dolist (elt TeX-bar-TeX-all-button-alists)
+                               (setq append-list (append append-list
+                                                         (eval elt))))
+                             append-list)))
+
 (defcustom TeX-bar-LaTeX-buttons
   '(open-file save-buffer cut copy paste undo
              [separator nil] latex next-error view bibtex)
@@ -184,7 +300,7 @@
   :type '(alist :key-type symbol :value-type sexp)
   :group 'TeX-tool-bar-button-definitions)
 
-;;; instalation of toolbar
+;;; Installation of the tool bar
 ;;;###autoload
 (defun LaTeX-install-toolbar ()
   "Install toolbar buttons for LaTeX mode."

--- tex.el      11 Jul 2006 21:20:05 -0000      5.583
+++ tex.el      26 Jul 2006 13:07:14 -0000
@@ -1859,6 +1859,18 @@
 (defvar TeX-grcl "}" "The TeX group closing character.")
  (make-variable-buffer-local 'TeX-grcl)
 
+(defcustom TeX-enable-toolbar t
+  "Enable TeX tool bar."
+  :group 'TeX-tool-bar
+  :type 'boolean)
+
+(defun TeX-maybe-install-toolbar ()
+  "Conditionally install tool bar buttons for TeX mode.
+Install tool bar if `TeX-enable-toolbar' is non-nil."
+  (when TeX-enable-toolbar
+    ;; Defined in `tex-bar.el':
+    (TeX-install-toolbar)))
+
 ;;; Symbols
 
 ;; Must be before keymaps.
@@ -2432,6 +2444,9 @@
   (setq TeX-base-mode-name "TeX")
   (setq TeX-command-default "TeX")
   (setq TeX-sentinel-default-function 'TeX-TeX-sentinel)
+  (add-hook 'tool-bar-mode-on-hook 'TeX-maybe-install-toolbar nil t)
+  (when (if (featurep 'xemacs) (featurep 'toolbar) tool-bar-mode)
+    (TeX-maybe-install-toolbar))
   (TeX-run-mode-hooks 'text-mode-hook 'TeX-mode-hook 'plain-TeX-mode-hook)
   (TeX-set-mode-name))
--8<---------------cut here---------------end--------------->8---

Bye, Reiner.
-- 
       ,,,
      (o o)
---ooO-(_)-Ooo---  |  PGP key available  |  http://rsteib.home.pages.de/





reply via email to

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