[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Texmacs-dev] shortcuts and big parenthesis
From: |
david |
Subject: |
[Texmacs-dev] shortcuts and big parenthesis |
Date: |
Thu, 10 Apr 2003 14:10:55 +0200 |
User-agent: |
Mutt/1.5.3i |
On Tue, Apr 08, 2003 at 11:51:44AM -0600, Nix N. Nix wrote:
> Hi!
>
> Over the past 3 weeks, while you guys were busy, I was brooding over a
> few things. Now, since you seem to be back in the swing of all things
> TeXmacs, I'd like to see what you think of them. For example:
Well, we are still quite busy... :-)
> I)
> (kbd-map in-math?
> ("C-_" (make-below))
> ("C-^" (make-above))
> ("M-A-~" (make-wide-under "~"))
> ("M-A-^" (make-wide-under "^"))
> ("M-A-B" (make-wide-under "<bar>"))
> ("M-A-V" (make-wide-under "<vect>"))
> ("M-A-C" (make-wide-under "<check>"))
> ("M-A-U" (make-wide-under "<breve>"))
> ("M-A-'" (make-wide-under "<acute>"))
> ("M-A-`" (make-wide-under "<grave>"))
> ("M-A-." (make-wide-under "<dot>"))
> ("M-A-\"" (make-wide-under "<ddot>")))
>
> Would there be any major problems adding these keyboard bindings ? For
> the longest time there has been a lack of symmetry between make-wide
> bindings and make-wide-under bindings. I use both, so this would really
> help. I currently have these in my my-init-texmacs.scm, but I don't see
> why these couldn't be added to kbd-math.scm.
Personally, I would see no problem in adding those, but I think Joris
will not like them. The reason is that they do not fit in the the
shorctut organization. See further.
> I don't know how to use all those wildcards you have created for the
> various bindings (like "math" and "math:greek" and "table" and the
> likes), so I don't really know how to make a patch of it.
This is Joris attempt to put organization in the big number of
shortcuts of TeXmacs. Yes, I know I once asked for "wilcarding keymap"
but I was thinking of something completely different.
Each keybord profile defines a number of "wildcards" (I would rather
call them keychords or key-aliases, because they are really nothing
like wildcards) which associate a "prefix" to one or several keychords.
For example "math" is "A-" or "esc esc".
Then families of shortcuts are built either reusing the base shortcut
or using a completely new one.
For example "math:bold" is "F6" and "math:left" is "math l" (that is
"A-l" or "esc esc l").
The idea is this kind of namespacing would make it easier to partially
redefine the keymaps.
In your example you use two keychord bases: "C-" and "M-A-".
Examination of kbd-emacs.scm (the default profile) shows that "C-" is
associated to "emacs", for is generic editor operations and insertion
of some format nodes.
"M-A-" is associated to "font" which is used in both math and text
context to change the shape of the font (though the shortcuts are
different).
Well, I like this shortcuts but I have no idea how we can make them
fit properly in the current organization.
Maybe use "math _" as "math:under"...
And for your two "C-" shortcuts, maybe we could define "math:crowded"
as an alias for "C-", reserved for useful shortcuts using horribly
overloaded keys...
> II)
> (define (make-brackets left right)
> (if (selection-active-normal?)
> (begin (cut "primary") (make-large-left left) (paste "primary")
> (let* ((pos (tm-position-new)) (old (tm-position-get pos)))
> (make-large-right right)
> (tm-go-to old)
> (tm-position-delete pos)))
> (begin (make-large-left left)
> (let* ((pos (tm-position-new)) (old (tm-position-get pos)))
> (make-large-right right)
> (tm-go-to old)
> (tm-position-delete pos)))))
>
> This is a hack.
You said it!
> - Programmatically placing the cursor between the brackets only works if
> this code is executed when the cursor is inside a (concat ...), i.e.,
>
> M-F2 $ (make-brackets "(" ")")
>
> doesn't place the cursor between the brackets, whereas
>
> M-F2 $ a (make-brackets "(" ")")
>
> does.
Not quite. In the first case the concat is created by
make-large-right, so the path you got with tm-position-get is no
longer what you expect.
In the second case, the concat is created by make-large-left, so
things work, but for the wrong reason.
To make your code work, you need to tm-position-get just at the moment
you tm-go-to.
But there is a simpler solution:
(define (make-brackets l r)
(let ((sel? (selection-active-normal?)))
(if sel? (cut "temp"))
(insert-object-go-to `(concat (left ,l) (right ,r)) '(1 0))
(if sel? (paste "temp"))))
> - Cutting to primary is a hack. I was unable to find Scheme that deals
> with manipulations of selections, other than the cut and paste
> function. I have talked to David about this (see our thread from
> around 2003-03-23). He said we could probably create some selection
> accessors.
Temporarily, I suggest you use the "temp" clipboard with (cut "temp")
and (paste "temp").
> Also, (make-brackets ...) would be a perfect candidate for additional
> useful keyboard bindings:
>
> (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 "|" "rangle")) ;; "ket"
> ("M-C-<" (make-brackets "langle" "|")) ;; "bra"
These might make sense. You just have to convince Joris. Designing
good keymaps is difficult and you have too keep an eye on the big
picture.
> I also have a question:
> How can I override existing keyboard bindings ? In earlier versions of
> TeXmacs, I could define a keyboard binding in my-init-texmacs.scm that
> was the same as the one for, say, (make-expand-arg "matrix"), and mine
> would override it with some other function. This no longer works. Is
> there something special I have to do in order to overwrite keyboard
> bindings ?
>
> Thank you for your attention. I will go grab TeXmacs 1.0.1.9 now.
Joris?
What is the current status of keyboard stuff?
Nobody understand the keyboard customization anymore.
--
-- DDAA