tex-symb

Masayuki Ataka <[email protected]>
Newsgroups gmane.emacs.auc-tex
Message-ID <[email protected]>
Hi,

I wrote tex-symb.el as `yet another X-Symbol EmacsLisp', which
only provides semi-WISYSIG environment on Emacs.  The current
code still have some problems, but it works!  Please, try elisp
attached this mail.  I believe 
  [screenshot|http://pop-club.hp.infoseek.co.jp/emacs/tex-symb.png]
will help you understanding what I want to do and want to say.

You see, tex-symb.el is similar to preview-latex.  But
tex-symb.el does not provide perfect preview environment; just
provide editable environment.  So, imagine the very long
equation; You have found something wrong in preview and you
should fix it; Typing C-c C-p C-p, you will see the long line,
which is full of TeX's mathematical macros; In such a case,
tex-symb.el is useful because most of math macros are folded
into one char symbol, which easy to look TeX source, and you
can edit them directly.

* Usage

tex-symb.el is written to override tex-fold.el, so only have to
do is load tex-symb.el and do tex-folding in your buffer.
Mathematical macros will be folded into symbols (with unicode
font).

** text-arrow

For example, \rightarrow is folded into one unicode character
(0x2192). If you feel right arrow is too short, try below.

  (setq TeX-fold-macro-spec-list
        (append TeX-symb-ascii-arrow-list TeX-symb-utf-math-list TeX-fold-macro-list))

\rightarrow will be `->' (2 characters in ascii code).

Similarly, `=>' for \Rightarrow, '-->' for \longrightarrow, so forth.


* X-Symbol [http://x-symbol.sourceforge.net/]

(cited from X-Symbol Hompepage)
When you edit LaTeX, HTML, BibTeX or TeXinfo sources in Emacs,
package X-Symbol provides some kind of WYSIWYG by using real
characters for tokens like \oplus or &trade;. It also provides
various input methods to insert these characters. Thumbnails
for included images and real super-/subscripts and are also
supported.


I want simple, small, smart code for semi-WISIWIG environment
specialized for TeX/Texinfo, because:

** X-Symbol replaces tex macros by other text (encode), decode
   it when copying and saving text, which sometimes leads us
   uncomfortable even with RefTeX, Version Control, Mule, etc...
** X-Symbol mainly developend on XEmacs (not GNU Emacs)
** Thumbnails for included images are supported by preview-latex.
** Real super-/subscripts are supported by font-latex.


* Bugs / Problems / Limitations

Note taht tex-symb.el is a baby program, just showing us what
tex-symb.el wants to do.

** Slow!

We should write new folding engine especially for TeX macros?

** TeX / Texinfo

We should cater for the Texinfo macros.  We should not use
folding rules for TeX macros when folding in Texinfo mode,
because most of them are not used in Texinfo.

** Match I

Sometimes, tex-symb does not fold TeX macros in CVS Emacs.
In such a case: 
  \leq\alpha
\leq is not folded because regexp `\\_>' in TeX-fold-region
matches `\'.

** Match II

Currently, The argument of \sqrt becomes invisible, because TeX
macros folding rule is automatically converted from
LaTeX-math-default, which has 
  (nil "sqrt" "Constructs" 8730) ;; #X221A

Similar TeX commands (ex. hat, bar, vec, etc...) have the same
problems.

** Latin-1,2,3,4,5

We want to fold \'a displaying with latin-1 char (or unicode).

** Some TeX macros are unsupported by current tex-fold
like ?` !` \$ \#.



Comments are mostly welcome.

regards,
---
email: [email protected]
Name:: Masayuki Ataka // (Japan)
tex-symb.el (text/plain, 2.8 KB)
;;; tex-symb.el --- TeX symbol macros.

;; Copyright (C) 2005 Free Software Foundation.

;; Author: Masayuki Ataka <[email protected]>
;; Maintainer: [email protected]
;; Created: 2005-03-03
;; Keywords: tex, wp

;; 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 2, 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., 59 Temple Place - Suite 330, Boston, MA
;; 02111-1307, USA.

;;; Commentary:

;; This file provides support for hiding and unhiding TeX, LaTeX, ContTeXt,
;; Texinfo and similar macros (especially for symbols) inside of AUCTeX.

;;; Code:

(require 'tex-fold)

(setq TeX-fold-macro-list
  '(("[f]" ("footnote"))
    ("[c]" ("cite"))
    ("[l]" ("label"))
    ("[r]" ("ref" "eqref"))
    ("[i]" ("index"))
    ("*" ("item"))
    ("..." ("dots"))
    (1 ("part" "chapter" "section" "subsection" "subsubsection"
	"paragraph" "subparagraph"
	"part*" "chapter*" "section*" "subsection*" "subsubsection*"
	"paragraph*" "subparagraph*"
	"emph" "textit" "textsl" "textmd" "textrm" "textsf" "texttt"
	"textbf" "textsc" "textup"))))

;; Arrow

(defvar TeX-symb-ascii-text-list
  '(("(C)" ("copyright"))
    ("(R)" ("textregistered"))
    ("TM" ("texttrademark"))
))

(defvar TeX-symb-ascii-arrow-list
  '(;; <-
    ("<-" ("leftarrow" "gets"))
    ("<=" ("Leftarrow"))
    ("<--" ("longleftarrow"))
    ("<==" ("Longleftarrow"))
    ;; ->
    ("->" ("rightarrow" "to"))
    ("=>" ("Rightarrow"))
    ("-->" ("longrightarrow"))
    ("==>" ("Longrightarrow"))
    ;; <->
    ("<->" ("leftrightarrow"))
    ("<=>" ("Leftrightarrow"))
    ("<-->" ("longleftrightarrow"))
    ("<==>" ("Longleftrightarrow")))
  "List of arrow (ascii)")

(defvar TeX-symb-utf-math-list nil)
(unless TeX-symb-utf-math-list
  (setq TeX-symb-utf-math-list
	(delete nil
		(mapcar (lambda (elt) 
			  (let* ((tex (nth 1 elt))
				 (unicode (nth 3 elt))
				 (uchar (and (integerp unicode) (decode-char 'ucs unicode))))
			    (when (and (stringp tex) (integerp uchar))
			      (list (char-to-string uchar) (list tex)))))
			LaTeX-math-default))))

(setq TeX-fold-macro-spec-list
;      (append TeX-symb-ascii-arrow-list TeX-symb-utf-math-list TeX-fold-macro-list))
      (append TeX-symb-utf-math-list TeX-fold-macro-list))

;; Provide ourselves:
(provide 'tex-symb)

;;; tex-symb.el ends here
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.