[Openmcl-devel] Smart quotes

Gary Byers gb at clozure.com
Tue Jul 14 19:43:33 PDT 2009



On Tue, 14 Jul 2009, Ron Garret wrote:

> Since CCL is unicode-enabled, I would like to hack Hemlock so that I
> can easily use directional quote characters like ?this? and ?this?.  I
> have a customized DefaultKeyBinding.dict that binds these characters
> to the (shift-)option-[ and (shift-)option-] key-events, which I know
> work because I used them to compose the previous sentence.  But if I
> do this:
>
> (bind-key "self insert" #k"meta-[")
>
> then option-[ gives me a square bracket, not a left-quote.  Looking
> through the code I don't see any straightforward way to bind a key to
> insert a character other than itself stripped of all modifiers.  I
> suppose I could do what I want by defining a custom command for each
> character, but that just seems horribly ugly.  Is there a better way
> to do this?  There would seem to be a lot of applications for this
> sort of thing in a unicode world, like maybe binding option-l to
> insert a greek lambda.
>
> Thanks,
> rg
>

The "Self Insert" command does something like (this is pseudocode and from
memory):

   (let* ((key-event (get-last-key-event))
          (char (get-character-from-key-event key-event))
          (point (current-point-for-insertion)))
     (insert-character point char))

e.g., the whole idea is to insert the character associated with the last key
event.  (The real command takes a parameter - an optional repeat count - and
may call INSERT-CHARACTER more than once if that parameter is a positive 
integer.)  That isn't what you want here, but it's similar.

(defcommand "Insert Left Double Quote" (p)
   "Insert a left double quote character at the current buffer's point,
    deleting any selected range before doint the insertion."
   "Secret doc string for developers"
   (setq p (or p 1))
   (let* ((point (current-point-for-insertion)))
     (dotimes (i p)
       (insert-character point #\u+201c))))

(defcommand "Insert Right Double Quote" (p)
   "Left As An Exercise"
   "Guess, but a right double quote is #\u+201d ."
)

(bind-key "Insert Left Double Quote" #k"meta-{")







> _______________________________________________
> Openmcl-devel mailing list
> Openmcl-devel at clozure.com
> http://clozure.com/mailman/listinfo/openmcl-devel
>
>



More information about the Openmcl-devel mailing list