emacs-devel
[Top][All Lists]
Advanced

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

Re: Insert character pairs


From: Juri Linkov
Subject: Re: Insert character pairs
Date: Sat, 01 May 2004 02:22:22 +0300
User-agent: Gnus/5.110002 (No Gnus v0.2) Emacs/21.3.50 (gnu/linux)

Stefan Monnier <address@hidden> writes:
>>>>>> The following patch generalizes the function `insert-parentheses'
>>>>> Why not start from skeleton-insert-paren-maybe ?
>>>> It doesn't work with key modifiers.
>>> That why I said "start" rather than "use".  I know it requires changes.
>> I am not sure that the meaning of arguments of `skeleton-insert-paren-maybe'
>> should be redefined.
> That's why I said "start with" rather than "change".
> Anyway, it's not like it makes any real difference.

Creating a function similar to `insert-parentheses' is very easy.
The following diff shows the needed changes (note that I don't propose
to change the existing function, this diff only demonstrates
the differences between the existing function and the new
`skeleton-pair-insert' function):

-(defun skeleton-pair-insert-maybe (arg)
+(defun skeleton-pair-insert (arg)
   (interactive "*P")
-  (if (or arg (not skeleton-pair))
+  (if (not skeleton-pair)
       (self-insert-command (prefix-numeric-value arg))
     (let* ((mark (and skeleton-autowrap
                      (or (eq last-command 'mouse-drag-region)
                          (and transient-mark-mode mark-active))))
           (skeleton-end-hook)
-          (char last-command-char)
+          (char (event-basic-type last-command-event))
           (skeleton (or (assq char skeleton-pair-alist)
                         (assq char skeleton-pair-default-alist)
                         `(,char _ ,char))))
       (if (or (memq (char-syntax (preceding-char)) '(?\\ ?/))
              (and (not mark)
                   (or overwrite-mode
                       (if (not skeleton-pair-on-word) (looking-at "\\w"))
                       (funcall skeleton-pair-filter))))
          (self-insert-command (prefix-numeric-value arg))
-       (skeleton-insert (cons nil skeleton) (if mark -1))))))
+       (skeleton-insert (cons nil skeleton) (if mark -1 (prefix-numeric-value 
arg)))))))

But I think my changes in `insert-parentheses' are useful too,
because these function are still different: `skeleton-insert'
counts words, but `insert-parentheses' counts s-expressions.
And there are other less important differences.

-- 
Juri Linkov
http://www.jurta.org/emacs/





reply via email to

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