unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Insert character pairs
@ 2004-04-29  8:48 Juri Linkov
  2004-04-29 10:12 ` Andreas Schwab
                   ` (3 more replies)
  0 siblings, 4 replies; 29+ messages in thread
From: Juri Linkov @ 2004-04-29  8:48 UTC (permalink / raw)


It is useful for efficient editing to be able to insert a pair of
symmetrical characters.  Emacs already provides the command M-( to
insert parentheses, but it would be good to extend this command for
other paired characters like quotes and brackets.

The following patch generalizes the function `insert-parentheses'
by changing its name, adding new arguments, and creating the
new function `insert-parentheses' with the old name that calls it.
Also it adds the functions for some most frequent character pairs
to be able to bind them to the keys like M-", M-', M-`, M-[.

And taking into account active regions is useful too.

Index: lisp/emacs-lisp/lisp.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/emacs-lisp/lisp.el,v
retrieving revision 1.52
diff -u -w -b -r1.52 lisp.el
--- lisp/emacs-lisp/lisp.el	14 Apr 2004 18:20:23 -0000	1.52
+++ lisp/emacs-lisp/lisp.el	29 Apr 2004 06:20:33 -0000
@@ -302,7 +306,7 @@
       (end-of-defun)
       (narrow-to-region beg (point)))))
 
-(defun insert-parentheses (arg)
+(defun insert-pair (arg &optional open close)
   "Enclose following ARG sexps in parentheses.  Leave point after open-paren.
 A negative ARG encloses the preceding ARG sexps instead.
 No argument is equivalent to zero: just insert `()' and leave point between.
@@ -311,20 +315,66 @@
   (interactive "P")
   (if arg (setq arg (prefix-numeric-value arg))
     (setq arg 0))
+  (or open  (setq open  ?\())
+  (or close (setq close ?\)))
+  (if (and transient-mark-mode mark-active)
+      (progn
+        (save-excursion (goto-char (region-beginning)) (insert open))
+        (save-excursion (goto-char (region-end))       (insert close)))
   (cond ((> arg 0) (skip-chars-forward " \t"))
 	((< arg 0) (forward-sexp arg) (setq arg (- arg))))
   (and parens-require-spaces
        (not (bobp))
-       (memq (char-syntax (preceding-char)) '(?w ?_ ?\) ))
+       (memq (char-syntax (preceding-char)) (list ?w ?_ close))
        (insert " "))
-  (insert ?\()
+  (insert open)
   (save-excursion
     (or (eq arg 0) (forward-sexp arg))
-    (insert ?\))
+    (insert close)
     (and parens-require-spaces
 	 (not (eobp))
-	 (memq (char-syntax (following-char)) '(?w ?_ ?\( ))
-	 (insert " "))))
+        (memq (char-syntax (following-char)) (list ?w ?_ open))
+        (insert " ")))))
+
+(defun insert-parentheses (arg)
+  "Insert a pair of parentheses."
+  (interactive "P")
+  (insert-pair arg ?\( ?\)))
+
+(defun insert-double-quotes (arg)
+  "Insert a pair of double quotes."
+  (interactive "P")
+  (insert-pair arg ?\" ?\"))
+
+(defun insert-backquotes (arg)
+  "Insert a pair of backquotes."
+  (interactive "P")
+  (insert-pair arg ?\` ?\`))
+
+(defun insert-backquote-and-quote (arg)
+  "Insert backquote and quote."
+  (interactive "P")
+  (insert-pair arg ?\` ?\'))
+
+(defun insert-apostrophes (arg)
+  "Insert a pair of apostrophes."
+  (interactive "P")
+  (insert-pair arg ?\' ?\'))
+
+(defun insert-square-brackets (arg)
+  "Insert a pair of square brackets."
+  (interactive "P")
+  (insert-pair arg ?\[ ?\]))
+
+(defun insert-curly-brackets (arg)
+  "Insert a pair of curly brackets."
+  (interactive "P")
+  (insert-pair arg ?\{ ?\}))
+
+(defun insert-angle-brackets (arg)
+  "Insert a pair of angle brackets."
+  (interactive "P")
+  (insert-pair arg ?\< ?\>))

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

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: Insert character pairs
  2004-04-29  8:48 Insert character pairs Juri Linkov
@ 2004-04-29 10:12 ` Andreas Schwab
  2004-04-29 11:00   ` Juri Linkov
  2004-04-29 14:24 ` Stefan Monnier
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 29+ messages in thread
From: Andreas Schwab @ 2004-04-29 10:12 UTC (permalink / raw)
  Cc: emacs-devel

Juri Linkov <juri@jurta.org> writes:

>    (and parens-require-spaces
>         (not (bobp))
> -       (memq (char-syntax (preceding-char)) '(?w ?_ ?\) ))
> +       (memq (char-syntax (preceding-char)) (list ?w ?_ close))

This won't work, the list contains syntax codes, not characters.

>      (and parens-require-spaces
>  	 (not (eobp))
> -	 (memq (char-syntax (following-char)) '(?w ?_ ?\( ))
> -	 (insert " "))))
> +        (memq (char-syntax (following-char)) (list ?w ?_ open))
> +        (insert " ")))))

Same here.

Andreas.

-- 
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux AG, Maxfeldstraße 5, 90409 Nürnberg, Germany
Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: Insert character pairs
  2004-04-29 10:12 ` Andreas Schwab
@ 2004-04-29 11:00   ` Juri Linkov
  2004-04-29 11:21     ` Andreas Schwab
  0 siblings, 1 reply; 29+ messages in thread
From: Juri Linkov @ 2004-04-29 11:00 UTC (permalink / raw)
  Cc: emacs-devel

Andreas Schwab <schwab@suse.de> writes:
> Juri Linkov <juri@jurta.org> writes:
>>    (and parens-require-spaces
>>         (not (bobp))
>> -       (memq (char-syntax (preceding-char)) '(?w ?_ ?\) ))
>> +       (memq (char-syntax (preceding-char)) (list ?w ?_ close))
>
> This won't work, the list contains syntax codes, not characters.

Actually, it does work for parentheses arguments, so it is
still backward compatible.  But, of course, you are right that
it should be fixed, because it makes no sense for other characters
whose syntax character doesn't coincide with the character itself.

To fix it, it seems reasonable to check for character syntax of
arguments before inserting a space, i.e. insert a space
when character syntax of adjacent characters is the same,
(plus ?w and ?_, i.e. inside words as it was before):

-       (memq (char-syntax (preceding-char)) '(?w ?_ ?\) ))
+       (memq (char-syntax (preceding-char)) (list ?w ?_ (char-syntax close)))

-       (memq (char-syntax (following-char)) '(?w ?_ ?\( ))
+       (memq (char-syntax (following-char)) (list ?w ?_ (char-syntax open)))

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

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: Insert character pairs
  2004-04-29 11:00   ` Juri Linkov
@ 2004-04-29 11:21     ` Andreas Schwab
  2004-04-29 11:59       ` Juri Linkov
  0 siblings, 1 reply; 29+ messages in thread
From: Andreas Schwab @ 2004-04-29 11:21 UTC (permalink / raw)
  Cc: emacs-devel

Juri Linkov <juri@jurta.org> writes:

> To fix it, it seems reasonable to check for character syntax of
> arguments before inserting a space, i.e. insert a space
> when character syntax of adjacent characters is the same,
> (plus ?w and ?_, i.e. inside words as it was before):
>
> -       (memq (char-syntax (preceding-char)) '(?w ?_ ?\) ))
> +       (memq (char-syntax (preceding-char)) (list ?w ?_ (char-syntax close)))

What's wrong with leaving it as it is?

Andreas.

-- 
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux AG, Maxfeldstraße 5, 90409 Nürnberg, Germany
Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: Insert character pairs
  2004-04-29 11:21     ` Andreas Schwab
@ 2004-04-29 11:59       ` Juri Linkov
  0 siblings, 0 replies; 29+ messages in thread
From: Juri Linkov @ 2004-04-29 11:59 UTC (permalink / raw)
  Cc: emacs-devel

Andreas Schwab <schwab@suse.de> writes:
> Juri Linkov <juri@jurta.org> writes:
>
>> To fix it, it seems reasonable to check for character syntax of
>> arguments before inserting a space, i.e. insert a space
>> when character syntax of adjacent characters is the same,
>> (plus ?w and ?_, i.e. inside words as it was before):
>>
>> -       (memq (char-syntax (preceding-char)) '(?w ?_ ?\) ))
>> +       (memq (char-syntax (preceding-char)) (list ?w ?_ (char-syntax close)))
>
> What's wrong with leaving it as it is?

I wanted to follow the same logic of inserting a space for
other possible character pairs: ", ', `, <>, [], {}.

For example, inserting a quote character next to an existing quote
character could insert a space between them.

Anyway, the docstring of `insert-parentheses' says:

"If `parens-require-spaces' is non-nil, this command also inserts a space
before and after, depending on the surrounding characters."

What does "depending on the surrounding characters" mean, when applied
to other characters, can be interpreted differently.

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

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: Insert character pairs
  2004-04-29  8:48 Insert character pairs Juri Linkov
  2004-04-29 10:12 ` Andreas Schwab
@ 2004-04-29 14:24 ` Stefan Monnier
  2004-04-29 15:02   ` Juri Linkov
  2004-05-01  8:19 ` Juri Linkov
  2004-05-01 20:26 ` Stefan Monnier
  3 siblings, 1 reply; 29+ messages in thread
From: Stefan Monnier @ 2004-04-29 14:24 UTC (permalink / raw)
  Cc: emacs-devel

> The following patch generalizes the function `insert-parentheses'

Why not start from skeleton-insert-paren-maybe ?


        Stefan

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: Insert character pairs
  2004-04-29 14:24 ` Stefan Monnier
@ 2004-04-29 15:02   ` Juri Linkov
  2004-04-29 16:57     ` Stefan Monnier
  0 siblings, 1 reply; 29+ messages in thread
From: Juri Linkov @ 2004-04-29 15:02 UTC (permalink / raw)
  Cc: emacs-devel

Stefan Monnier <monnier@iro.umontreal.ca> writes:
>> The following patch generalizes the function `insert-parentheses'
>
> Why not start from skeleton-insert-paren-maybe ?

It doesn't work with key modifiers.

However, this could be partly fixed by replacing `last-command-char'
with `(event-basic-type last-command-event)'.

But still usage of function arguments of `skeleton-pair-insert-maybe'
and `insert-parentheses' is very different:

`skeleton-pair-insert-maybe' uses its argument to insert the typed
character ARG times (which still doesn't work with modifiers),
while `insert-parentheses' encloses ARG sexps in parentheses.

I think the latter is better.  But perhaps `skeleton-pair-insert-maybe'
could be improved to interpret its argument like `insert-parentheses'?

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

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: Insert character pairs
  2004-04-29 15:02   ` Juri Linkov
@ 2004-04-29 16:57     ` Stefan Monnier
  2004-04-30  0:48       ` Juri Linkov
  0 siblings, 1 reply; 29+ messages in thread
From: Stefan Monnier @ 2004-04-29 16:57 UTC (permalink / raw)
  Cc: emacs-devel

>>> 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.


        Stefan

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: Insert character pairs
  2004-04-29 16:57     ` Stefan Monnier
@ 2004-04-30  0:48       ` Juri Linkov
  2004-04-30 13:43         ` Stefan Monnier
  0 siblings, 1 reply; 29+ messages in thread
From: Juri Linkov @ 2004-04-30  0:48 UTC (permalink / raw)
  Cc: emacs-devel

Stefan Monnier <monnier@iro.umontreal.ca> 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.  It clearly declares its purpose by the first line
of docstring:

"Insert the character you type ARG times."

So, perhaps, a new function could be created with a different purpose.

But then why create a new function if the existing `open-parenthesis'
can be easily improved with retaining backward compatibility?

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

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: Insert character pairs
  2004-04-30  0:48       ` Juri Linkov
@ 2004-04-30 13:43         ` Stefan Monnier
  2004-04-30 23:22           ` Juri Linkov
  0 siblings, 1 reply; 29+ messages in thread
From: Stefan Monnier @ 2004-04-30 13:43 UTC (permalink / raw)
  Cc: emacs-devel

>>>>> 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.


        Stefan

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: Insert character pairs
  2004-04-30 13:43         ` Stefan Monnier
@ 2004-04-30 23:22           ` Juri Linkov
  0 siblings, 0 replies; 29+ messages in thread
From: Juri Linkov @ 2004-04-30 23:22 UTC (permalink / raw)
  Cc: emacs-devel

Stefan Monnier <monnier@iro.umontreal.ca> 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/

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: Insert character pairs
  2004-04-29  8:48 Insert character pairs Juri Linkov
  2004-04-29 10:12 ` Andreas Schwab
  2004-04-29 14:24 ` Stefan Monnier
@ 2004-05-01  8:19 ` Juri Linkov
  2004-05-02 16:19   ` Juri Linkov
  2004-05-03 19:48   ` Kevin Rodgers
  2004-05-01 20:26 ` Stefan Monnier
  3 siblings, 2 replies; 29+ messages in thread
From: Juri Linkov @ 2004-05-01  8:19 UTC (permalink / raw)


> Also it adds the functions for some most frequent character pairs
> to be able to bind them to the keys like M-", M-', M-`, M-[.

It seems all these functions might be added only with adding
the corresponding key bindings at the same time.  But some keys
are already bound: M-' to abbrev-prefix-mark, M-` to tmm-menubar,
M-{ to backward-paragraph.  M-" and M-[ are unbound, but they
might be reserved to something different.

Anyhow, the function `open-pair' allows everyone to bind a key
to `open-pair' with desired character arguments in .emacs.

BTW, I didn't find anywhere in Emacs a command that promotes
a list up in the tree.  It would be useful to add this command
to `emacs-lisp/lisp.el':

(defun promote-list (&optional arg)
  "Promote expressions higher up the tree."
  (interactive "p")
  (let ((str (if (and transient-mark-mode mark-active)
                 (buffer-substring (region-beginning) (region-end))
               (buffer-substring
                (point)
                (save-excursion (forward-sexp arg) (point))))))
    (backward-up-list 1)
    (delete-region (point) (save-excursion (forward-sexp 1) (point)))
    (save-excursion (insert str))))

Maybe, a better name is `move-up-list' (however, not good since
the word `move' often means `move the point') or `lift-up-list'?

The command `promote-list' is basically opposite to `insert-parentheses',
so another possible name is `remove-parentheses', but it is misleading,
because it removes more than only enclosing parentheses.

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

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: Insert character pairs
  2004-04-29  8:48 Insert character pairs Juri Linkov
                   ` (2 preceding siblings ...)
  2004-05-01  8:19 ` Juri Linkov
@ 2004-05-01 20:26 ` Stefan Monnier
  2004-05-02 16:03   ` Juri Linkov
  3 siblings, 1 reply; 29+ messages in thread
From: Stefan Monnier @ 2004-05-01 20:26 UTC (permalink / raw)
  Cc: emacs-devel

[ Let's make my suggestion more concrete, then. ]

> +(defun insert-parentheses (arg)
> +(defun insert-double-quotes (arg)
> +(defun insert-backquotes (arg)
> +(defun insert-backquote-and-quote (arg)
> +(defun insert-apostrophes (arg)
> +(defun insert-square-brackets (arg)
> +(defun insert-curly-brackets (arg)
> +(defun insert-angle-brackets (arg)

Using last-command-char or some such would allow you to define just one
command that does all those things.


        Stefan

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: Insert character pairs
  2004-05-01 20:26 ` Stefan Monnier
@ 2004-05-02 16:03   ` Juri Linkov
  2004-05-02 16:41     ` Stefan Monnier
  0 siblings, 1 reply; 29+ messages in thread
From: Juri Linkov @ 2004-05-02 16:03 UTC (permalink / raw)
  Cc: emacs-devel

Stefan Monnier <monnier@iro.umontreal.ca> writes:
> [ Let's make my suggestion more concrete, then. ]
>
>> +(defun insert-parentheses (arg)
>> +(defun insert-double-quotes (arg)
>> +(defun insert-backquotes (arg)
>> +(defun insert-backquote-and-quote (arg)
>> +(defun insert-apostrophes (arg)
>> +(defun insert-square-brackets (arg)
>> +(defun insert-curly-brackets (arg)
>> +(defun insert-angle-brackets (arg)
>
> Using last-command-char or some such would allow you to define just one
> command that does all those things.

This looks like `skeleton-pair-insert-maybe', but perhaps to converge
the functionality of `skeleton-pair-insert-maybe' and `insert-pair'
is not a bad thing.  However, they still have some fundamental
differences like different text units (words vs. expressions)
specified by their arguments.

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

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: Insert character pairs
  2004-05-01  8:19 ` Juri Linkov
@ 2004-05-02 16:19   ` Juri Linkov
  2004-05-03 14:03     ` Richard Stallman
  2004-05-04 15:57     ` Johan Bockgård
  2004-05-03 19:48   ` Kevin Rodgers
  1 sibling, 2 replies; 29+ messages in thread
From: Juri Linkov @ 2004-05-02 16:19 UTC (permalink / raw)


> Maybe, a better name is `move-up-list' (however, not good since
> the word `move' often means `move the point') or `lift-up-list'?
>
> The command `promote-list' is basically opposite to `insert-parentheses',
> so another possible name is `remove-parentheses', but it is misleading,
> because it removes more than only enclosing parentheses.

I propose to bind `rise-up-list' to currently unused `C-x C-M-u'.
The reason is that it is similar to `backward-up-list' (`C-M-u'),
but with the prefix C-x will move the list backward out of one level
of parentheses instead of moving the point as `backward-up-list' does.

And while on this topic, another suggestion is to add a prefix
argument to the command C-M-q (`indent-sexp') which currently
has no prefix argument.  This can be similar to M-q (`fill-paragraph')
whose prefix argument adds a special meaning to justify paragraphs.
C-M-q without prefix will work exactly as it currently works,
but with a prefix will pretty-print the list after point.
This is relevant only for emacs-lisp-mode and buffers
in lisp-interaction-mode like the *scratch* buffer.

Index: lisp/emacs-lisp/lisp-mode.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/emacs-lisp/lisp-mode.el,v
retrieving revision 1.155
diff -U4 -r1.155 lisp-mode.el
--- lisp/emacs-lisp/lisp-mode.el	22 Mar 2004 15:31:46 -0000	1.155
+++ lisp/emacs-lisp/lisp-mode.el	2 May 2004 15:13:58 -0000
@@ -238,8 +238,9 @@
     (setq emacs-lisp-mode-map (make-sparse-keymap))
     (set-keymap-parent emacs-lisp-mode-map lisp-mode-shared-map)
     (define-key emacs-lisp-mode-map "\e\t" 'lisp-complete-symbol)
     (define-key emacs-lisp-mode-map "\e\C-x" 'eval-defun)
+    (define-key emacs-lisp-mode-map "\e\C-q" 'indent-or-pp-sexp)
     (define-key emacs-lisp-mode-map [menu-bar] (make-sparse-keymap))
     (define-key emacs-lisp-mode-map [menu-bar emacs-lisp]
       (cons "Emacs-Lisp" map))
     (define-key map [edebug-defun]
@@ -368,8 +369,9 @@
 (defvar lisp-interaction-mode-map
   (let ((map (make-sparse-keymap)))
     (set-keymap-parent map lisp-mode-shared-map)
     (define-key map "\e\C-x" 'eval-defun)
+    (define-key map "\e\C-q" 'indent-or-pp-sexp)
     (define-key map "\e\t" 'lisp-complete-symbol)
     (define-key map "\n" 'eval-print-last-sexp)
     map)
   "Keymap for Lisp Interaction mode.
@@ -1082,8 +1084,19 @@
       (and (bolp) (not (eolp))
 	   (lisp-indent-line))
       (indent-sexp endmark)
       (set-marker endmark nil))))
+
+(defun indent-or-pp-sexp (&optional arg)
+  "Indent each line of the list or, with argument, pretty-printify the list."
+  (interactive "P")
+  (if arg
+      (let* (p (str (pp-to-string (save-excursion
+                                    (prog1 (read (current-buffer))
+                                      (setq p (point)))))))
+        (delete-region (point) p)
+        (save-excursion (insert str)))
+    (indent-sexp)))
 
 ;;;; Lisp paragraph filling commands.
 
 (defcustom emacs-lisp-docstring-fill-column 65

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

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: Insert character pairs
  2004-05-02 16:03   ` Juri Linkov
@ 2004-05-02 16:41     ` Stefan Monnier
  0 siblings, 0 replies; 29+ messages in thread
From: Stefan Monnier @ 2004-05-02 16:41 UTC (permalink / raw)
  Cc: emacs-devel

>> Using last-command-char or some such would allow you to define just one
>> command that does all those things.

> This looks like `skeleton-pair-insert-maybe', but perhaps to converge
> the functionality of `skeleton-pair-insert-maybe' and `insert-pair'
> is not a bad thing.  However, they still have some fundamental
> differences like different text units (words vs. expressions)
> specified by their arguments.

My remarks have all to do with the code, not the UI, here.  So implement
whichever functionality you (and others) think is fit.  I'm only interested
in using last-command-char to merge all those functions into one.


        Stefan

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: Insert character pairs
  2004-05-02 16:19   ` Juri Linkov
@ 2004-05-03 14:03     ` Richard Stallman
  2004-05-04 15:57     ` Johan Bockgård
  1 sibling, 0 replies; 29+ messages in thread
From: Richard Stallman @ 2004-05-03 14:03 UTC (permalink / raw)
  Cc: emacs-devel

    I propose to bind `rise-up-list' to currently unused `C-x C-M-u'.
    The reason is that it is similar to `backward-up-list' (`C-M-u'),
    but with the prefix C-x will move the list backward out of one level
    of parentheses instead of moving the point as `backward-up-list' does.

It is true that sometimes we use C-x for a related command.  But this
feels not quite right.  Partly that's because we have no bindings on
C-M- characters after C-x.  (Such combinations are a little hard to type.)

It is an acceptable choice, but I think we should first try to look at
other options.  If we can't find anything better then let's use C-x
C-M-u.

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: Insert character pairs
  2004-05-01  8:19 ` Juri Linkov
  2004-05-02 16:19   ` Juri Linkov
@ 2004-05-03 19:48   ` Kevin Rodgers
  2004-05-04  5:51     ` Juri Linkov
  1 sibling, 1 reply; 29+ messages in thread
From: Kevin Rodgers @ 2004-05-03 19:48 UTC (permalink / raw)


Juri Linkov wrote:
 > BTW, I didn't find anywhere in Emacs a command that promotes
 > a list up in the tree.  It would be useful to add this command
 > to `emacs-lisp/lisp.el':
 >
 > (defun promote-list (&optional arg)
 >   "Promote expressions higher up the tree."
 >   (interactive "p")
 >   (let ((str (if (and transient-mark-mode mark-active)
 >                  (buffer-substring (region-beginning) (region-end))
 >                (buffer-substring
 >                 (point)
 >                 (save-excursion (forward-sexp arg) (point))))))
 >     (backward-up-list 1)
 >     (delete-region (point) (save-excursion (forward-sexp 1) (point)))
 >     (save-excursion (insert str))))
 >
 > Maybe, a better name is `move-up-list' (however, not good since
 > the word `move' often means `move the point') or `lift-up-list'?

Yes, "move" would be misleading.

 > The command `promote-list' is basically opposite to `insert-parentheses',
 > so another possible name is `remove-parentheses', but it is misleading,
 > because it removes more than only enclosing parentheses.

I don't find "delete" or "remove" misleading at all.

-- 
Kevin Rodgers

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: Insert character pairs
  2004-05-03 19:48   ` Kevin Rodgers
@ 2004-05-04  5:51     ` Juri Linkov
  2004-05-04 18:30       ` Kevin Rodgers
  0 siblings, 1 reply; 29+ messages in thread
From: Juri Linkov @ 2004-05-04  5:51 UTC (permalink / raw)
  Cc: emacs-devel

Kevin Rodgers <ihs_4664@yahoo.com> writes:
> Juri Linkov wrote:
>  > Maybe, a better name is `move-up-list' (however, not good since
>  > the word `move' often means `move the point') or `lift-up-list'?
>
> Yes, "move" would be misleading.
>
>  > The command `promote-list' is basically opposite to `insert-parentheses',
>  > so another possible name is `remove-parentheses', but it is misleading,
>  > because it removes more than only enclosing parentheses.
>
> I don't find "delete" or "remove" misleading at all.

"delete" or "remove" would not be misleading if they correctly
indicated what is removed, but the name may become too long,
e.g. "remove-parentheses-and-non-selected-text".

Perhaps `rise-up-sexp' is a better name.

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

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: Insert character pairs
  2004-05-02 16:19   ` Juri Linkov
  2004-05-03 14:03     ` Richard Stallman
@ 2004-05-04 15:57     ` Johan Bockgård
  2004-05-04 16:48       ` Juri Linkov
  2004-05-05 20:20       ` Richard Stallman
  1 sibling, 2 replies; 29+ messages in thread
From: Johan Bockgård @ 2004-05-04 15:57 UTC (permalink / raw)


Juri Linkov <juri@jurta.org> writes:

> And while on this topic, another suggestion is to add a prefix
> argument to the command C-M-q (`indent-sexp') which currently has no
> prefix argument. This can be similar to M-q (`fill-paragraph') whose
> prefix argument adds a special meaning to justify paragraphs. C-M-q
> without prefix will work exactly as it currently works, but with a
> prefix will pretty-print the list after point. This is relevant only
> for emacs-lisp-mode and buffers in lisp-interaction-mode like the
> *scratch* buffer.

[...]

> +(defun indent-or-pp-sexp (&optional arg)
> +  "Indent each line of the list or, with argument, pretty-printify the list."
> +  (interactive "P")
> +  (if arg
> +      (let* (p (str (pp-to-string (save-excursion
> +                                    (prog1 (read (current-buffer))
                                                ^
But this would also lead to all comments being removed , right?

> +                                      (setq p (point)))))))
> +        (delete-region (point) p)
> +        (save-excursion (insert str)))
> +    (indent-sexp)))

-- 
Johan Bockgård

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: Insert character pairs
  2004-05-04 15:57     ` Johan Bockgård
@ 2004-05-04 16:48       ` Juri Linkov
  2004-05-05 20:20       ` Richard Stallman
  1 sibling, 0 replies; 29+ messages in thread
From: Juri Linkov @ 2004-05-04 16:48 UTC (permalink / raw)


bojohan+news@dd.chalmers.se (Johan Bockgård) writes:
> Juri Linkov <juri@jurta.org> writes:
>> +(defun indent-or-pp-sexp (&optional arg)
>> +  "Indent each line of the list or, with argument, pretty-printify the list."
>> +  (interactive "P")
>> +  (if arg
>> +      (let* (p (str (pp-to-string (save-excursion
>> +                                    (prog1 (read (current-buffer))
>                                                 ^
> But this would also lead to all comments being removed , right?

Right.  I already thought about this problem recently and tried to
solve it somehow.  Below is the version that calls `pp-to-string'
with a string with all comments preserved, and removes newlines
except at comments.  However, it still don't work right and I'm
not sure I should continue to modify `pp-to-string'.  That is why
I asked on this list today about such existing function that can
format Emacs Lisp code prettier than `pp'.

(defun indent-or-pp-sexp (&optional arg)
  "Indent each line of the list or, with argument, pretty-printify the list."
  (interactive "P")
  (if arg
      (let* (p (s (pp-to-string
                      (if (and transient-mark-mode mark-active)
                          (buffer-substring (region-beginning)
                                            (setq p (region-end)))
                        (buffer-substring
                         (point) (save-excursion (forward-sexp 1)
                                                 (setq p (point))))) t)))
        (delete-region (point) p)
        (save-excursion (insert s)))
    (indent-sexp)))

diff -u pp.el~ pp.el
--- pp.el~	2004-03-23 07:11:29
+++ pp.el	2004-05-04 11:29:17
@@ -37,7 +37,7 @@
 
 ;;;###autoload
-(defun pp-to-string (object)
+(defun pp-to-string (object &optional as-string)
   "Return a string containing the pretty-printed representation of OBJECT.
 OBJECT can be any Lisp object.  Quoting characters are used as needed
 to make output that `read' can handle, whenever this is possible."
@@ -49,7 +49,19 @@
 	  (set-syntax-table emacs-lisp-mode-syntax-table)
 	  (let ((print-escape-newlines pp-escape-newlines)
 		(print-quoted t))
-	    (prin1 object (current-buffer)))
+	    (if (not (and as-string (stringp object)))
+                (prin1 object (current-buffer))
+              (princ object (current-buffer))
+              ;; Remove newlines except ones at comments
+              (comment-normalize-vars)
+              (goto-char (point-min))
+              (goto-char (line-end-position))
+              (while (not (eobp))
+                (if (not (comment-beginning))
+                    (delete-char 1)
+                  (forward-line 1))
+                (goto-char (line-end-position)))))
 	  (goto-char (point-min))
 	  (while (not (eobp))

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

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: Insert character pairs
  2004-05-04  5:51     ` Juri Linkov
@ 2004-05-04 18:30       ` Kevin Rodgers
  2004-05-04 19:32         ` Juri Linkov
  0 siblings, 1 reply; 29+ messages in thread
From: Kevin Rodgers @ 2004-05-04 18:30 UTC (permalink / raw)


Juri Linkov wrote:
 > Kevin Rodgers <ihs_4664@yahoo.com> writes:
 > >Juri Linkov wrote:
 > > > The command `promote-list' is basically opposite to `insert-parentheses',
 > > > so another possible name is `remove-parentheses', but it is misleading,
 > > > because it removes more than only enclosing parentheses.
 > >
 > > I don't find "delete" or "remove" misleading at all.
 >
 > "delete" or "remove" would not be misleading if they correctly
 > indicated what is removed, but the name may become too long,
 > e.g. "remove-parentheses-and-non-selected-text".

Right.  But remove- would be bad because no other commands use that
prefix.  I think delete- is better.

How about delete-surrounding-sexps, delete-sibling-sexps, or
just-one-sexp (in analogy to just-one-space)?

 > Perhaps `rise-up-sexp' is a better name.

I think "raise [up]" is the correct English verb (because it is
transitive, whereas "rise [up]" is intransitive).  But the Emacs command
should be named after its surface effect anyway, not its deep
(structural) effect.  Or are you proposing that insert-parentheses
should be named demote-sexp?  :-)

-- 
Kevin Rodgers

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: Insert character pairs
  2004-05-04 18:30       ` Kevin Rodgers
@ 2004-05-04 19:32         ` Juri Linkov
  2004-05-05 20:20           ` Richard Stallman
  0 siblings, 1 reply; 29+ messages in thread
From: Juri Linkov @ 2004-05-04 19:32 UTC (permalink / raw)
  Cc: emacs-devel

Kevin Rodgers <ihs_4664@yahoo.com> writes:
> Juri Linkov wrote:
>  > Kevin Rodgers <ihs_4664@yahoo.com> writes:
>  > >Juri Linkov wrote:
>  > > > The command `promote-list' is basically opposite to `insert-parentheses',
>  > > > so another possible name is `remove-parentheses', but it is misleading,
>  > > > because it removes more than only enclosing parentheses.
>  > >
>  > > I don't find "delete" or "remove" misleading at all.
>  >
>  > "delete" or "remove" would not be misleading if they correctly
>  > indicated what is removed, but the name may become too long,
>  > e.g. "remove-parentheses-and-non-selected-text".
>
> Right.  But remove- would be bad because no other commands use that
> prefix.  I think delete- is better.
>
> How about delete-surrounding-sexps, delete-sibling-sexps, or
> just-one-sexp (in analogy to just-one-space)?

Good names, but not completely true.  Actually, this function deletes
all the text inside the sexp out of one level of parentheses, except
sexps selected by the argument or active region in transient-mark-mode.
So deleted text may contain comments as well.

>  > Perhaps `rise-up-sexp' is a better name.
>
> I think "raise [up]" is the correct English verb (because it is
> transitive, whereas "rise [up]" is intransitive).  But the Emacs command
> should be named after its surface effect anyway, not its deep
> (structural) effect.  Or are you proposing that insert-parentheses
> should be named demote-sexp?  :-)

No, it should be named lower-sexp :-)

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

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: Insert character pairs
  2004-05-04 15:57     ` Johan Bockgård
  2004-05-04 16:48       ` Juri Linkov
@ 2004-05-05 20:20       ` Richard Stallman
  2004-05-06 13:14         ` Juri Linkov
  1 sibling, 1 reply; 29+ messages in thread
From: Richard Stallman @ 2004-05-05 20:20 UTC (permalink / raw)
  Cc: emacs-devel

    > +      (let* (p (str (pp-to-string (save-excursion
    > +                                    (prog1 (read (current-buffer))
						    ^
    But this would also lead to all comments being removed , right?

Yes, it would.  So people would only want to use this in
special situations.

In the past, I think I've seen mechanisms that allow the Lisp
reader to remember where there were comments and associate the comments
with the surrounding code.  But that's a big job, not a simple
change like the one here proposed.

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: Insert character pairs
  2004-05-04 19:32         ` Juri Linkov
@ 2004-05-05 20:20           ` Richard Stallman
  2004-05-06 12:02             ` Juri Linkov
  0 siblings, 1 reply; 29+ messages in thread
From: Richard Stallman @ 2004-05-05 20:20 UTC (permalink / raw)
  Cc: ihs_4664, emacs-devel

    Good names, but not completely true.  Actually, this function deletes
    all the text inside the sexp out of one level of parentheses, except
    sexps selected by the argument or active region in transient-mark-mode.

The name delete-surrounding-sexp would fit that command, but
that doesn't seem like a very useful command.

I had misunderstood the previous description; I though the idea was
to delete just the parentheses, more or less the opposite of what
insert-parentheses does.  The name delete-surrounding-sexp would
not fit that at all, but raise-sexp or promote-sexp would fit it.

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: Insert character pairs
  2004-05-05 20:20           ` Richard Stallman
@ 2004-05-06 12:02             ` Juri Linkov
  0 siblings, 0 replies; 29+ messages in thread
From: Juri Linkov @ 2004-05-06 12:02 UTC (permalink / raw)
  Cc: ihs_4664, emacs-devel

Richard Stallman <rms@gnu.org> writes:
>     Good names, but not completely true.  Actually, this function deletes
>     all the text inside the sexp out of one level of parentheses, except
>     sexps selected by the argument or active region in transient-mark-mode.
>
> The name delete-surrounding-sexp would fit that command, but
> that doesn't seem like a very useful command.
>
> I had misunderstood the previous description; I though the idea was
> to delete just the parentheses, more or less the opposite of what
> insert-parentheses does.  The name delete-surrounding-sexp would
> not fit that at all, but raise-sexp or promote-sexp would fit it.

This suggests that actually two separate commands would be useful:
`delete-parentheses' and `raise-sexp'.

Both would operate on the sexp that follows point, with the
difference that the latter simply deletes enclosing parentheses,
and the former deletes the whole surrounding sexp excluding some
selected inner sexps.

Both are useful: `delete-parentheses' is useful to delete not only
parentheses, but any enclosing characters, including all kinds of
quotes.  And `raise-sexp' is very handy for editing Emacs Lisp
programs to replace the surrounding sexp by selected inner sexps:
e.g. to move sexps from `if' condition, from `save-excursion' and
in many other similar situations.  For example, suppose that there
is the need to change `(save-excursion (insert s))' into `(insert s)'.
Currently, this requires too many keystrokes.  `raise-sexp' will
allow to do this with only one command.

Index: emacs/lisp/emacs-lisp/lisp.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/emacs-lisp/lisp.el,v
retrieving revision 1.53
diff -u -r1.53 lisp.el
--- emacs/lisp/emacs-lisp/lisp.el	1 May 2004 03:58:43 -0000	1.53
+++ emacs/lisp/emacs-lisp/lisp.el	6 May 2004 11:56:44 -0000
@@ -348,6 +371,27 @@

+(defun delete-pair ()
+  "Delete a pair of characters enclosing the sexp that follows point."
+  (interactive)
+  (save-excursion (forward-sexp 1) (delete-char -1))
+  (delete-char 1))
+
+(defalias 'delete-parentheses 'delete-pair)
+
+(defun raise-sexp (&optional arg)
+  "Raise ARG sexps higher up the tree."
+  (interactive "p")
+  (let ((s (if (and transient-mark-mode mark-active)
+               (buffer-substring (region-beginning) (region-end))
+             (buffer-substring
+              (point)
+              (save-excursion (forward-sexp arg) (point))))))
+    (backward-up-list 1)
+    (delete-region (point) (save-excursion (forward-sexp 1) (point)))
+    (save-excursion (insert s))))

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

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: Insert character pairs
  2004-05-05 20:20       ` Richard Stallman
@ 2004-05-06 13:14         ` Juri Linkov
  2004-05-06 17:19           ` Stefan Monnier
  0 siblings, 1 reply; 29+ messages in thread
From: Juri Linkov @ 2004-05-06 13:14 UTC (permalink / raw)
  Cc: emacs-devel, bojohan+news

Richard Stallman <rms@gnu.org> writes:
>     > +      (let* (p (str (pp-to-string (save-excursion
>     > +                                    (prog1 (read (current-buffer))
> 						    ^
>     But this would also lead to all comments being removed , right?
>
> Yes, it would.  So people would only want to use this in
> special situations.

I think it should be harmless in all situations.  Luckily, it is possible
to achieve this easily with minimal modifications in `pp-to-string':

Index: emacs/lisp/emacs-lisp/pp.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/emacs-lisp/pp.el,v
retrieving revision 1.21
diff -u -r1.21 pp.el
--- emacs/lisp/emacs-lisp/pp.el	22 Mar 2004 15:32:24 -0000	1.21
+++ emacs/lisp/emacs-lisp/pp.el	6 May 2004 12:07:31 -0000
@@ -37,10 +37,13 @@
   :group 'pp)
 
 ;;;###autoload
-(defun pp-to-string (object)
+(defun pp-to-string (object &optional as-string)
   "Return a string containing the pretty-printed representation of OBJECT.
 OBJECT can be any Lisp object.  Quoting characters are used as needed
-to make output that `read' can handle, whenever this is possible."
+to make output that `read' can handle, whenever this is possible.
+Optional argument AS-STRING means that OBJECT is treated as
+a string containing the printed representation of Lisp data.
+The function modifies this string and returns it pretty-printed."
   (save-excursion
     (set-buffer (generate-new-buffer " pp-to-string"))
     (unwind-protect
@@ -49,7 +52,9 @@
 	  (set-syntax-table emacs-lisp-mode-syntax-table)
 	  (let ((print-escape-newlines pp-escape-newlines)
 		(print-quoted t))
-	    (prin1 object (current-buffer)))
+	    (if (not (and as-string (stringp object)))
+                (prin1 object (current-buffer))
+              (princ object (current-buffer))))
 	  (goto-char (point-min))
 	  (while (not (eobp))
 	    ;; (message "%06d" (- (point-max) (point)))
@@ -60,8 +65,10 @@
 	      (save-excursion
 		(backward-char 1)
 		(skip-chars-backward "'`#^")
-		(when (and (not (bobp)) (= ?\ (char-before)))
-		  (delete-char -1)
+		(when (and (not (bobp)) (memq (char-before) '(?\ ?\t ?\n)))
+		  (delete-region
+		   (point)
+		   (progn (skip-chars-backward " \t\n") (point)))
 		  (insert "\n"))))
 	     ((condition-case err-var
 		  (prog1 t (up-list 1))
@@ -70,7 +77,7 @@
 		(forward-char 1))
 	      (delete-region
 	       (point)
-	       (progn (skip-chars-forward " \t") (point)))
+	       (progn (skip-chars-forward " \t\n") (point)))
 	      (insert ?\n))
 	     (t (goto-char (point-max)))))
 	  (goto-char (point-min))
Index: emacs/lisp/emacs-lisp/lisp-mode.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/emacs-lisp/lisp-mode.el,v
retrieving revision 1.155
diff -u -r1.155 lisp-mode.el
--- emacs/lisp/emacs-lisp/lisp-mode.el	22 Mar 2004 15:31:46 -0000	1.155
+++ emacs/lisp/emacs-lisp/lisp-mode.el	6 May 2004 13:07:32 -0000
@@ -239,6 +239,7 @@
     (set-keymap-parent emacs-lisp-mode-map lisp-mode-shared-map)
     (define-key emacs-lisp-mode-map "\e\t" 'lisp-complete-symbol)
     (define-key emacs-lisp-mode-map "\e\C-x" 'eval-defun)
+    (define-key emacs-lisp-mode-map "\e\C-q" 'indent-or-pp-sexp)
     (define-key emacs-lisp-mode-map [menu-bar] (make-sparse-keymap))
     (define-key emacs-lisp-mode-map [menu-bar emacs-lisp]
       (cons "Emacs-Lisp" map))
@@ -369,6 +370,7 @@
   (let ((map (make-sparse-keymap)))
     (set-keymap-parent map lisp-mode-shared-map)
     (define-key map "\e\C-x" 'eval-defun)
+    (define-key map "\e\C-q" 'indent-or-pp-sexp)
     (define-key map "\e\t" 'lisp-complete-symbol)
     (define-key map "\n" 'eval-print-last-sexp)
     map)
@@ -1083,6 +1085,27 @@
 	   (lisp-indent-line))
       (indent-sexp endmark)
       (set-marker endmark nil))))
+
+(defun indent-or-pp-sexp (&optional arg)
+  "Indent each line of the list or, with argument, pretty-printify the list."
+  (interactive "P")
+  (if arg
+      (let* (p
+             (s (pp-to-string
+                 (buffer-substring
+                  (point)
+                  (save-excursion
+                    (forward-sexp 1)
+                    (setq p (point))))
+                 t)))
+        (delete-region (point) p)
+        (save-excursion
+          (insert s)
+          (if (eq (char-before) ?\n)
+              (delete-char -1)))
+        (indent-sexp))
+    (indent-sexp)))
 
 ;;;; Lisp paragraph filling commands.

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

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: Insert character pairs
  2004-05-06 13:14         ` Juri Linkov
@ 2004-05-06 17:19           ` Stefan Monnier
  2004-05-08 21:43             ` Juri Linkov
  0 siblings, 1 reply; 29+ messages in thread
From: Stefan Monnier @ 2004-05-06 17:19 UTC (permalink / raw)
  Cc: bojohan+news, rms, emacs-devel

> +(defun pp-to-string (object &optional as-string)

Yuck!

Why not just move the formatting part of pp-to-string out of pp-to-string
into a new function pp-format or some such (and make pp-to-string call it)?
That will also make pp-to-string more readable.


        Stefan

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: Insert character pairs
  2004-05-06 17:19           ` Stefan Monnier
@ 2004-05-08 21:43             ` Juri Linkov
  0 siblings, 0 replies; 29+ messages in thread
From: Juri Linkov @ 2004-05-08 21:43 UTC (permalink / raw)
  Cc: bojohan+news, rms, emacs-devel

Stefan Monnier <monnier@iro.umontreal.ca> writes:
> Why not just move the formatting part of pp-to-string out of pp-to-string
> into a new function pp-format or some such (and make pp-to-string call it)?
> That will also make pp-to-string more readable.

Actually, I started to implement the variant you described, but
abandoned it, because I thought that ability to format a string
in `pp-to-string' might be generally useful.  However, formatting
a string will be equally easy even with a separate function that
formats a buffer (by inserting that string into a temporary buffer).
So a separate function you described is ok (I'd name it `pp-buffer').

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

^ permalink raw reply	[flat|nested] 29+ messages in thread

end of thread, other threads:[~2004-05-08 21:43 UTC | newest]

Thread overview: 29+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-04-29  8:48 Insert character pairs Juri Linkov
2004-04-29 10:12 ` Andreas Schwab
2004-04-29 11:00   ` Juri Linkov
2004-04-29 11:21     ` Andreas Schwab
2004-04-29 11:59       ` Juri Linkov
2004-04-29 14:24 ` Stefan Monnier
2004-04-29 15:02   ` Juri Linkov
2004-04-29 16:57     ` Stefan Monnier
2004-04-30  0:48       ` Juri Linkov
2004-04-30 13:43         ` Stefan Monnier
2004-04-30 23:22           ` Juri Linkov
2004-05-01  8:19 ` Juri Linkov
2004-05-02 16:19   ` Juri Linkov
2004-05-03 14:03     ` Richard Stallman
2004-05-04 15:57     ` Johan Bockgård
2004-05-04 16:48       ` Juri Linkov
2004-05-05 20:20       ` Richard Stallman
2004-05-06 13:14         ` Juri Linkov
2004-05-06 17:19           ` Stefan Monnier
2004-05-08 21:43             ` Juri Linkov
2004-05-03 19:48   ` Kevin Rodgers
2004-05-04  5:51     ` Juri Linkov
2004-05-04 18:30       ` Kevin Rodgers
2004-05-04 19:32         ` Juri Linkov
2004-05-05 20:20           ` Richard Stallman
2004-05-06 12:02             ` Juri Linkov
2004-05-01 20:26 ` Stefan Monnier
2004-05-02 16:03   ` Juri Linkov
2004-05-02 16:41     ` Stefan Monnier

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).