[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Texmacs-dev] Bracket convenience
From: |
david |
Subject: |
Re: [Texmacs-dev] Bracket convenience |
Date: |
Fri, 21 Mar 2003 12:34:08 +0100 |
User-agent: |
Mutt/1.5.3i |
On Thu, Mar 20, 2003 at 09:42:57PM -0700, Nix N. Nix wrote:
> (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"
Seems essentially okay to me, but I do not think that implementation
is acceptable. The main problem is that it would mutate the clipboard.
Copy is implicit when selecting text with the mouse (in conformance
with X11 tradition) but it is not implicit when selecting text with
the keyboard.
Generally, it would be nice to have simple and efficient mechanisms to
operate on the selection from Scheme. I can think of three approaches,
each useful for a different purpose:
A. Extract the selection, convert to scheme tree, apply a filter on
it, and overwrite the selection by the result, optionnally
preserving selection-active.
Good for generic filters, but destructive of hidden cursor
positions etc.
B. Introduce additional concats and documents if needed to make the
selection a single tree in the buffer, then pass the path of that
tree to a function which will mutate the document and optionnally
return the new bounds of the selection.
Good for specific structural operations like make-brackets.
C. Just call a procedure with the bounds of the selection, and get
back the new bounds of the selection from it.
Generic low-level operation from which A and B can be derived.
Useful to implement additional selection operation modes.
There would also probably a need for other selection operation modes
for tables, but that is another discussion entirely.
-- DDAA
Re: [Texmacs-dev] Bracket convenience, Nix N. Nix, 2003/03/21
Re: [Texmacs-dev] Bracket convenience, Álvaro Tejero Cantero, 2003/03/21