texmacs-dev
[Top][All Lists]
Advanced

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

[Texmacs-dev] Bracket convenience


From: Nix N. Nix
Subject: [Texmacs-dev] Bracket convenience
Date: 20 Mar 2003 21:42:57 -0700

How about introducing a convenient way to create pairs of brackets ?

We already have A-( for large left '(', etc. How about having a function
that produces a matching pair ? Not only that, but it should first cut
the selection, if there is one, then insert the selection between the
matched brackets.

This was one of the first things I've implemented when I first found
TeXmacs (0.3.x.x).  However, I used custom macros and stuff like that to
do it:

<assign|roundbrackets|<macro|x|<left|(><arg|x><right|)>>>

Then, I assigned C-( and C-) to (make-expand-arg "roundbrackets")

Not a very pretty solution, especially if you want to copy say, only the
opening bracket and not the closing bracket.  So, how about this:

(define (make-brackets left right)
  (if (selection-active-normal?)
    (begin (cut "primary") (make-large-left left)
      (paste "primary") (make-large-right right))
    (begin (make-large-left left) (make-large-right right))))

accompanied by:

(kbd-map in-math?
("C-(" (make-brackets "(" ")"))
("C-)" (make-brackets "(" ")"))
("C-[" (make-brackets "[" "]"))
("C-]" (make-brackets "[" "]"))
("C-{" (make-brackets "{" "}"))
("C-}" (make-brackets "{" "}"))
("C-<" (make-brackets "langle" "rangle"))
("C->" (make-brackets "langle" "rangle"))
("C-|" (make-brackets "|" "|"))
("C-:" (make-brackets "||" "||"))
("M-C->" (make-brackets "|" ">"))  ;; Used in Quantum Mechanics: "bra"
("M-C-<" (make-brackets "<" "|"))) ;; Used in Quantum Mechanics: "ket"

These are the shortcuts I have been using essentially forever.  It might
be a cool idea to have them in TeXmacs.  What do you think ?





reply via email to

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