* Pretty-printing .newsrc.eld
@ 2007-06-10 17:30 Giorgos Keramidas
2007-06-14 7:27 ` Katsumi Yamaoka
0 siblings, 1 reply; 6+ messages in thread
From: Giorgos Keramidas @ 2007-06-10 17:30 UTC (permalink / raw)
To: ding
Hi all,
this is probably not a Gnus-specific question, but it was
triggered after trying to search in my `.newsrc.eld' for
something, so if you can help that's fine, but if I should post
to another mailing list address that's fine too.
Is there any way to ``pretty-print'' my `.newsrc.eld' file?
It currently contains parts which look like this:
,-----------------------------------------------------------------------
| ("comp.lang.c" 3 ((1
| . 595414) (595416 . 595423) 595426 595428 595432 (595434
| . 595435) 595439 (595441 . 595442) 595445 595447 (595452
| . 595453) 595455 (595457 . 595458) 595470 595479 (595486
| . 595487) (595495 . 595500) 595502 595507 (595510
| . 595511) (595513 . 595515) 595518 595521 595523 595526 [...]
`-----------------------------------------------------------------------
After taking a backup copy, I managed to make parts of it look
like this instead:
,-----------------------------------------------------------------------
| ("comp.lang.c" 3 ((1 . 595414) (595416 . 595423) 595426 595428
| 595432 (595434 . 595435) 595439
| (595441 . 595442) 595445 595447
| (595452 . 595453) 595455 (595457 . 595458)
| 595470 595479 (595486 . 595487)
| (595495 . 595500) 595502 595507
| (595510 . 595511) (595513 . 595515)
| 595518 595521 595523 595526 [...]
`-----------------------------------------------------------------------
But every time Gnus fires up and rewrites this file, it is saved
with the first format (i.e. lacking indentation).
Is there any way to make Gnus save `.newsrc.eld' using the second
style, i.e. something that it a wee bit easier to skim through
using `M-x view-mode' or similar?
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Pretty-printing .newsrc.eld
2007-06-10 17:30 Pretty-printing .newsrc.eld Giorgos Keramidas
@ 2007-06-14 7:27 ` Katsumi Yamaoka
2007-06-14 19:24 ` Reiner Steib
0 siblings, 1 reply; 6+ messages in thread
From: Katsumi Yamaoka @ 2007-06-14 7:27 UTC (permalink / raw)
To: Giorgos Keramidas; +Cc: ding
[-- Attachment #1: Type: text/plain, Size: 427 bytes --]
>>>>> In <20070610173005.GA1276@kobe.laptop> Giorgos Keramidas wrote:
> this is probably not a Gnus-specific question, but it was
> triggered after trying to search in my `.newsrc.eld' for
> something, so if you can help that's fine, but if I should post
> to another mailing list address that's fine too.
> Is there any way to ``pretty-print'' my `.newsrc.eld' file?
Intresting. I lost no time in trying it. Here it is:
[-- Attachment #2: Type: application/emacs-lisp, Size: 392 bytes --]
[-- Attachment #3: Type: text/plain, Size: 1060 bytes --]
It works, however it takes too much time and the ones it makes
are not very easy to read. :<
[...]
> ,-----------------------------------------------------------------------
>| ("comp.lang.c" 3 ((1 . 595414) (595416 . 595423) 595426 595428
>| 595432 (595434 . 595435) 595439
>| (595441 . 595442) 595445 595447
>| (595452 . 595453) 595455 (595457 . 595458)
>| 595470 595479 (595486 . 595487)
>| (595495 . 595500) 595502 595507
>| (595510 . 595511) (595513 . 595515)
>| 595518 595521 595523 595526 [...]
> `-----------------------------------------------------------------------
> But every time Gnus fires up and rewrites this file, it is saved
> with the first format (i.e. lacking indentation).
> Is there any way to make Gnus save `.newsrc.eld' using the second
> style, i.e. something that it a wee bit easier to skim through
> using `M-x view-mode' or similar?
Maybe we need a better and faster function that replaces `pp'.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Pretty-printing .newsrc.eld
2007-06-14 7:27 ` Katsumi Yamaoka
@ 2007-06-14 19:24 ` Reiner Steib
2007-06-15 6:59 ` Katsumi Yamaoka
0 siblings, 1 reply; 6+ messages in thread
From: Reiner Steib @ 2007-06-14 19:24 UTC (permalink / raw)
To: ding
On Thu, Jun 14 2007, Katsumi Yamaoka wrote:
> (add-hook
> 'gnus-save-quick-newsrc-hook
> (lambda nil
> "Pretty print Lisp objects in the .newsrc.eld file."
[...]
> (pp obj cur)))))
>
> It works, however it takes too much time and the ones it makes
> are not very easy to read. :<
I have the following poor man's pretty print in this hook:
(defun rs-gnus-save-newsrc-with-whitespace-1 ()
"Save ~/.newsrc.eld with extra whitespace."
;; <oq1ykgajdm.fsf@carouge.sram.qc.ca>
(gnus-message 5 "Adding whitespace to .newsrc.eld")
(save-excursion
(goto-char (point-min))
(while (re-search-forward "(\\\"\\| ((\\| (nn" nil t)
(replace-match "\n \\&" t))
(delete-trailing-whitespace)))
Additionally, I added newlines to make `forward-paragraph' work. I
think this one could be installed in the trunk.
--8<---------------cut here---------------start------------->8---
--- gnus-start.el 7 Jun 2007 11:59:35 -0000 7.50
+++ gnus-start.el 14 Jun 2007 19:22:37 -0000
@@ -2866,7 +2866,7 @@
(while variables
(when (and (boundp (setq variable (pop variables)))
(symbol-value variable))
- (princ "(setq ")
+ (princ "\n(setq ")
(princ (symbol-name variable))
(princ " '")
(prin1 (symbol-value variable))
--8<---------------cut here---------------end--------------->8---
Bye, Reiner.
--
,,,
(o o)
---ooO-(_)-Ooo--- | PGP key available | http://rsteib.home.pages.de/
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Pretty-printing .newsrc.eld
2007-06-14 19:24 ` Reiner Steib
@ 2007-06-15 6:59 ` Katsumi Yamaoka
2007-06-15 17:32 ` Reiner Steib
0 siblings, 1 reply; 6+ messages in thread
From: Katsumi Yamaoka @ 2007-06-15 6:59 UTC (permalink / raw)
To: ding
>>>>> In <v9odji9w5h.fsf@marauder.physik.uni-ulm.de>
>>>>> Reiner Steib wrote:
> On Thu, Jun 14 2007, Katsumi Yamaoka wrote:
>> It works, however it takes too much time and the ones it makes
>> are not very easy to read. :<
> I have the following poor man's pretty print in this hook:
> (defun rs-gnus-save-newsrc-with-whitespace-1 ()
> "Save ~/.newsrc.eld with extra whitespace."
This took 6 seconds while the rich man's version took 18 seconds
(in the condition where: (length gnus-newsrc-alist) => 1552).
> Additionally, I added newlines to make `forward-paragraph' work. I
> think this one could be installed in the trunk.
> --- gnus-start.el 7 Jun 2007 11:59:35 -0000 7.50
> +++ gnus-start.el 14 Jun 2007 19:22:37 -0000
> @@ -2866,7 +2866,7 @@
> (while variables
> (when (and (boundp (setq variable (pop variables)))
> (symbol-value variable))
> - (princ "(setq ")
> + (princ "\n(setq ")
> (princ (symbol-name variable))
> (princ " '")
> (prin1 (symbol-value variable))
It seems useful for a few people including me. ;-) Though it
might be sufficient to such people to do that by a hook:
(add-hook
'gnus-save-quick-newsrc-hook
(lambda nil
(goto-char (point-min))
(while (search-forward "\n(setq " nil t)
(replace-match "\n\n(setq "))))
It took 0.012 seconds.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Pretty-printing .newsrc.eld
2007-06-15 6:59 ` Katsumi Yamaoka
@ 2007-06-15 17:32 ` Reiner Steib
2007-06-16 11:31 ` Katsumi Yamaoka
0 siblings, 1 reply; 6+ messages in thread
From: Reiner Steib @ 2007-06-15 17:32 UTC (permalink / raw)
To: ding
On Fri, Jun 15 2007, Katsumi Yamaoka wrote:
>>>>>> Reiner Steib wrote:
>> I have the following poor man's pretty print in this hook:
>
>> (defun rs-gnus-save-newsrc-with-whitespace-1 ()
>> "Save ~/.newsrc.eld with extra whitespace."
>
> This took 6 seconds while the rich man's version took 18 seconds
> (in the condition where: (length gnus-newsrc-alist) => 1552).
Hm. For me it writes the file in less than a second (with a length of
650).
> It seems useful for a few people including me. ;-) Though it
> might be sufficient to such people to do that by a hook:
[...]
> (while (search-forward "\n(setq " nil t)
> (replace-match "\n\n(setq "))))
>
> It took 0.012 seconds.
I'd guess that...
- (princ "(setq ")
+ (princ "\n(setq ")
... doesn't add any noticeable delay and nobody will be disturbed by the
extra newline. So I will commit it.
Bye, Reiner.
--
,,,
(o o)
---ooO-(_)-Ooo--- | PGP key available | http://rsteib.home.pages.de/
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Pretty-printing .newsrc.eld
2007-06-15 17:32 ` Reiner Steib
@ 2007-06-16 11:31 ` Katsumi Yamaoka
0 siblings, 0 replies; 6+ messages in thread
From: Katsumi Yamaoka @ 2007-06-16 11:31 UTC (permalink / raw)
To: ding
>>>>> In <v9r6od6s3l.fsf@marauder.physik.uni-ulm.de>
>>>>> Reiner Steib <reinersteib+gmane@imap.cc> wrote:
>>> (defun rs-gnus-save-newsrc-with-whitespace-1 ()
>>> "Save ~/.newsrc.eld with extra whitespace."
>> This took 6 seconds while the rich man's version took 18 seconds
>> (in the condition where: (length gnus-newsrc-alist) => 1552).
> Hm. For me it writes the file in less than a second (with a length of
> 650).
The reason it was too slow might be that I was displaying the
buffer visiting the .newsrc.eld file while trying your function.
I cannot verify it since I'm now home and don't have many groups.
Sorry.
> I'd guess that...
> - (princ "(setq ")
> + (princ "\n(setq ")
> ... doesn't add any noticeable delay and nobody will be disturbed by the
> extra newline. So I will commit it.
Please go ahead.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2007-06-16 11:31 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-06-10 17:30 Pretty-printing .newsrc.eld Giorgos Keramidas
2007-06-14 7:27 ` Katsumi Yamaoka
2007-06-14 19:24 ` Reiner Steib
2007-06-15 6:59 ` Katsumi Yamaoka
2007-06-15 17:32 ` Reiner Steib
2007-06-16 11:31 ` Katsumi Yamaoka
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 NNTP newsgroup(s).