help-gnu-emacs
[Top][All Lists]
Advanced

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

equivalent to xemacs face-width?


From: Miguel Frasson
Subject: equivalent to xemacs face-width?
Date: 28 Oct 2003 16:12:36 +0100
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2

Hi

I am trying to port the package latex-symbols to gnu emacs, but I only
know the basics on lisp.

What is the GNU emacs equivalent to face-width? The code of a xemacs
function follows.

Thanks.

Miguel.

(defun ls-display-symbols (arg)
  "Pop up window showing all symbols of type ARG.
ARG may be one of
   'greek         to show greek letters
   'operators     to show binary operators
   'relations     to show binary relations
   'arrows        to show arrows
   'miscellany    to show everything else
   'other         to show other symbols
   'all           to show everything

   'plain         to show symbols defined in plain TeX/LaTeX
   'latexsym      to show symbols defined in latexsym.sty
   'amsfonts      to show symbols defined in amsfonts.sty
   'amsmath       to show symbols defined in amsmath.sty
   'amssymb       to show symbols defined in amssymb.sty
   'amsthm        to show symbols defined in amsthm.sty
   'stmaryrd      to show symbols defined in stmaryrd.sty"
  (let ((symbol-list
         (cdr
          (assoc
           arg
           (list (cons 'greek ls-greek)
                 (cons 'operators ls-ops)
                 (cons 'relations ls-rels)
                 (cons 'arrows ls-arrows)
                 (cons 'miscellany ls-misc)
                 (cons 'other ls-other)
                 (cons 'all ls-all)
                 (cons 'plain ls-plain)
                 (cons 'latexsym ls-latexsym)
                 (cons 'amsfonts ls-amsfonts)
                 (cons 'amsmath ls-amsmath)
                 (cons 'amssymb ls-amssymb)
                 (cons 'amsthm ls-amsthm)
                 (cons 'stmaryrd ls-stmaryrd)))))
        (bufname (concat " *(La)TeX symbols: " (symbol-name arg)))
        col1 col2 col3
        third
        max-length
        (default-width (face-width 'default))
        (spaces 5)
        (old-window (selected-window))
        glyph
        extent
        (row 1) (column 1))
    (if symbol-list
        (progn
          (with-output-to-temp-buffer bufname
            (setq third (/ (+ 2 (length symbol-list)) 3)
                  max-length (apply 'max (mapcar 'length symbol-list)))
            (while symbol-list
              (cond
               ((= column 1)
                (setq col1 (cons (car symbol-list) col1)))
               ((= column 2)
                (setq col2 (cons (car symbol-list) col2)))
               ((= column 3)
                (setq col3 (cons (car symbol-list) col3))))
              (setq symbol-list (cdr symbol-list))
              (if (eq row third)
                  (setq row 1
                        column (1+ column))
                (setq row (1+ row))))
            (setq col1 (nreverse col1))
            (setq col2 (nreverse col2))
            (setq col3 (nreverse col3))
            (while (or col1 col2 col3)
              (setq glyph
                    (make-glyph
                     (vector latex-symbol-picture-type
                             :file
                             (expand-file-name
                              (concat "STRUT."
                                      (ls-picture-type-name))
                              (expand-file-name
                               (ls-picture-type-name)
                               latex-symbol-directory)))))
              (set-glyph-property glyph 'baseline 50)
              (save-excursion
                (set-buffer (get-buffer bufname))
                (setq extent (make-extent (point) (point))))
              (set-extent-begin-glyph extent glyph)
              (princ "     ")
              (if col1
                  (progn
                    (setq spaces
                          (- 5
                             (/ (ls-draw-sym (car col1) bufname)
                                default-width)))
                    (princ (make-string
                            (+ spaces
                               (- max-length (length (car col1))))
                            ?\ ))
                    (setq col1 (cdr col1))))
              (if col2
                  (progn
                    (setq spaces
                          (- 5
                             (/ (ls-draw-sym (car col2) bufname)
                                default-width)))
                    (princ (make-string
                            (+ spaces
                               (- max-length (length (car col2))))
                            ?\ ))
                    (setq col2 (cdr col2))))
              (if col3
                  (progn
                    (ls-draw-sym (car col3) bufname)
                    (setq col3 (cdr col3))))
              (terpri)))
          (save-excursion
            (select-window (get-buffer-window (get-buffer bufname)))
            (setq truncate-lines t)
            (select-window old-window)))
      (message "Unknown symbol type: %s" (symbol-name arg)))))

-- 
Miguel Vinicius Santini Frasson
http://www.math.leidenuniv.nl/~frasson


reply via email to

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