Gnus development mailing list
 help / color / mirror / Atom feed
* Customize citation character
@ 2012-01-18  2:42 Philipp Haselwarter
  2012-01-18  3:57 ` Katsumi Yamaoka
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Philipp Haselwarter @ 2012-01-18  2:42 UTC (permalink / raw)
  To: ding

Is it possible to /visually/ replace the leading `> ' in citations with
something else, like `│ ' ?


-- 
Philipp Haselwarter



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

* Re: Customize citation character
  2012-01-18  2:42 Customize citation character Philipp Haselwarter
@ 2012-01-18  3:57 ` Katsumi Yamaoka
  2012-01-18  7:31   ` Reiner Steib
  2012-01-18  6:17 ` Martin
  2012-01-18  8:48 ` Eric S Fraga
  2 siblings, 1 reply; 10+ messages in thread
From: Katsumi Yamaoka @ 2012-01-18  3:57 UTC (permalink / raw)
  To: ding

philipp.haselwarter@gmx.de wrote:
> Is it possible to /visually/ replace the leading `> ' in citations with
> something else, like `│ ' ?

Is this ok?

(add-hook 'gnus-article-prepare-hook
	  (lambda nil
	    (goto-char (point-min))
	    (let ((inhibit-read-only t))
	      (while (re-search-forward "^[\t >]+" nil t)
		(replace-match (subst-char-in-string
				?> ?| (match-string 0)))))))



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

* Re: Customize citation character
  2012-01-18  2:42 Customize citation character Philipp Haselwarter
  2012-01-18  3:57 ` Katsumi Yamaoka
@ 2012-01-18  6:17 ` Martin
  2012-01-18  8:48 ` Eric S Fraga
  2 siblings, 0 replies; 10+ messages in thread
From: Martin @ 2012-01-18  6:17 UTC (permalink / raw)
  To: ding


Philipp Haselwarter writes:

> Is it possible to /visually/ replace the leading `> ' in citations with
> something else, like `│ ' ?

Customize message-yank-cited-prefix ?

Cheers

Martin




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

* Re: Customize citation character
  2012-01-18  3:57 ` Katsumi Yamaoka
@ 2012-01-18  7:31   ` Reiner Steib
  2012-01-18 17:58     ` Yagnesh Raghava Yakkala
  0 siblings, 1 reply; 10+ messages in thread
From: Reiner Steib @ 2012-01-18  7:31 UTC (permalink / raw)
  To: ding

On Wed, Jan 18 2012, Katsumi Yamaoka wrote:

> philipp.haselwarter@gmx.de wrote:
> | Is it possible to /visually/ replace the leading `> ' in citations with
> | something else, like `│ ' ?
>
> Is this ok?
>
> (add-hook 'gnus-article-prepare-hook
[...]
> 		(replace-match (subst-char-in-string
> 				?> ?| (match-string 0)))))))

That's probably not /visually/ because it also affects followups as
demonstrated above.

I think using display strings might be an option (untested).

(info "(elisp)Display Property"), (info "(elisp)Other Display Specs")

,----[ (info "(elisp)Other Display Specs") ]
| `STRING'
|      Display STRING instead of the text that has this property.
`----

Bye, Reiner.
-- 
       ,,,
      (o o)
---ooO-(_)-Ooo---  |  PGP key available  |  http://rsteib.home.pages.de/




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

* Re: Customize citation character
  2012-01-18  2:42 Customize citation character Philipp Haselwarter
  2012-01-18  3:57 ` Katsumi Yamaoka
  2012-01-18  6:17 ` Martin
@ 2012-01-18  8:48 ` Eric S Fraga
  2012-01-18 10:06   ` Eric S Fraga
  2 siblings, 1 reply; 10+ messages in thread
From: Eric S Fraga @ 2012-01-18  8:48 UTC (permalink / raw)
  To: ding

Philipp Haselwarter <philipp.haselwarter@gmx.de> writes:

> Is it possible to /visually/ replace the leading `> ' in citations with
> something else, like `│ ' ?

A small suggestion and request: don't customise this too much, if at
all.  Many of us fontify or otherwise manipulate our emails based on
patterns to identify included citations etc.  For instance, I typically
have cited emails hidden (cf. gnus-treat-hide-citation).  Standards
and/or conventions are there for a reason.  If it ain't broke...

Thanks,
eric

-- 
: Eric S Fraga (GnuPG: 0xC89193D8FFFCF67D) in Emacs 24.0.90.1 + No Gnus v0.18



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

* Re: Customize citation character
  2012-01-18  8:48 ` Eric S Fraga
@ 2012-01-18 10:06   ` Eric S Fraga
  0 siblings, 0 replies; 10+ messages in thread
From: Eric S Fraga @ 2012-01-18 10:06 UTC (permalink / raw)
  To: ding

Eric S Fraga <e.fraga@ucl.ac.uk> writes:

> Philipp Haselwarter <philipp.haselwarter@gmx.de> writes:
>
>> Is it possible to /visually/ replace the leading `> ' in citations with
>> something else, like `│ ' ?
>
> A small suggestion and request: don't customise this too much, if at
> all.  Many of us fontify or otherwise manipulate our emails based on
> patterns to identify included citations etc.  For instance, I typically
> have cited emails hidden (cf. gnus-treat-hide-citation).  Standards
> and/or conventions are there for a reason.  If it ain't broke...
>
> Thanks,
> eric

Apologies for the noise.  I have just re-read the original post and I
misunderstood it.

thanks,
eric

-- 
: Eric S Fraga (GnuPG: 0xC89193D8FFFCF67D) in Emacs 24.0.92.1 + No Gnus v0.18



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

* Re: Customize citation character
  2012-01-18  7:31   ` Reiner Steib
@ 2012-01-18 17:58     ` Yagnesh Raghava Yakkala
  2012-01-18 18:15       ` Yagnesh Raghava Yakkala
  0 siblings, 1 reply; 10+ messages in thread
From: Yagnesh Raghava Yakkala @ 2012-01-18 17:58 UTC (permalink / raw)
  To: ding


Modified version of Yamaoka-san snippet with Reiners' pointer 

(add-hook 'gnus-article-prepare-hook
          (lambda nil
            (let ((style "  | ")
                  (inhibit-read-only t))
              (save-excursion
                (goto-char (point-min))
                (while (re-search-forward "^[\t >]+" nil t)
                  (put-text-property
                   (match-beginning 0) (match-end 0)
                                     'display style))))))

can be further improved by calculating number of ">" in there and
placing that many "|" with different colors.

--
YYR




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

* Re: Customize citation character
  2012-01-18 17:58     ` Yagnesh Raghava Yakkala
@ 2012-01-18 18:15       ` Yagnesh Raghava Yakkala
  2012-01-19 19:24         ` Philipp Haselwarter
  0 siblings, 1 reply; 10+ messages in thread
From: Yagnesh Raghava Yakkala @ 2012-01-18 18:15 UTC (permalink / raw)
  To: ding

Yagnesh Raghava Yakkala <yagnesh@live.com> writes:

> Modified version of Yamaoka-san snippet with Reiners' pointer 
>
> (add-hook 'gnus-article-prepare-hook
>           (lambda nil
>             (let ((style "  | ")
>                   (inhibit-read-only t))
>               (save-excursion
>                 (goto-char (point-min))
>                 (while (re-search-forward "^[\t >]+" nil t)
>                   (put-text-property
>                    (match-beginning 0) (match-end 0)
>                                      'display style))))))
>
> can be further improved by calculating number of ">" in there and
> placing that many "|" with different colors.


oops. scratch that. blind copying of regex.

(add-hook 'gnus-article-prepare-hook
          (lambda nil
            (let ((cite-look "  |")
                  (inhibit-read-only t))
              (save-excursion
                (goto-char (point-min))
                (while (re-search-forward "^[\t ]?>+" nil t)
                  (put-text-property
                   (match-beginning 0) (match-end 0)
                                     'display cite-look))))))

did I get it correctly this time .?




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

* Re: Customize citation character
  2012-01-18 18:15       ` Yagnesh Raghava Yakkala
@ 2012-01-19 19:24         ` Philipp Haselwarter
  2012-01-19 21:13           ` Yagnesh Raghava Yakkala
  0 siblings, 1 reply; 10+ messages in thread
From: Philipp Haselwarter @ 2012-01-19 19:24 UTC (permalink / raw)
  To: Yagnesh Raghava Yakkala; +Cc: ding

Thanks for all the input, here's what I've come up with so far:

--8<---------------cut here---------------start------------->8---
(defcustom my-citation-look '("" "│" "")
  "(prefix citation-string suffix)" :group 'my)

(defun my-citation-style nil
  (let ((inhibit-read-only t)
        (alist gnus-cite-face-list)
        cflist face gnus-cite-prefix-alist)
    (save-excursion
      (gnus-narrow-to-body)
      (gnus-cite-parse)
      (dolist (prefix gnus-cite-prefix-alist) ;(reverse
        (setq cflist (append cflist (list (car alist)))
              alist (cdr alist))
        (let* ((current-cflist cflist)
               (depth (length cflist))
               (len (length (car prefix)))
               (look
                (concat
                 (car my-citation-look)
                 (mapconcat
                  (lambda (s) (propertize s 'face (pop current-cflist)))
                  (make-vector depth (cadr my-citation-look)) "")
                         (caddr my-citation-look))))
          (dolist (line (cdr prefix))
            (goto-char (point-min)) (forward-line (1- line))
            (put-text-property (point) (+ (point) len) 'display look)))))
    (widen)))
--8<---------------cut here---------------end--------------->8---

I'm quite satisfied with the results, although the usage of
`gnus-cite-prefix-alist' could probably be better: Sometimes it becomes
a little overzealous, for example in gmane.emacs.orgmode:51261 (OT:
better way to link articles?).

Someone with a better understanding of gnus internals could probably
figure out how to fix this.

-- 
Philipp Haselwarter



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

* Re: Customize citation character
  2012-01-19 19:24         ` Philipp Haselwarter
@ 2012-01-19 21:13           ` Yagnesh Raghava Yakkala
  0 siblings, 0 replies; 10+ messages in thread
From: Yagnesh Raghava Yakkala @ 2012-01-19 21:13 UTC (permalink / raw)
  To: ding

Philipp Haselwarter <philipp.haselwarter@gmx.de> writes:

> Thanks for all the input, here's what I've come up with so far:
>
> (defcustom my-citation-look '("" "│" "")
>   "(prefix citation-string suffix)" :group 'my)
>
> (defun my-citation-style nil
>   (let ((inhibit-read-only t)
>         (alist gnus-cite-face-list)
>         cflist face gnus-cite-prefix-alist)
>     (save-excursion
>       (gnus-narrow-to-body)
>       (gnus-cite-parse)
>       (dolist (prefix gnus-cite-prefix-alist) ;(reverse
>         (setq cflist (append cflist (list (car alist)))
>               alist (cdr alist))
>         (let* ((current-cflist cflist)
>                (depth (length cflist))
>                (len (length (car prefix)))
>                (look
>                 (concat
>                  (car my-citation-look)
>                  (mapconcat
>                   (lambda (s) (propertize s 'face (pop current-cflist)))
>                   (make-vector depth (cadr my-citation-look)) "")
>                          (caddr my-citation-look))))
>           (dolist (line (cdr prefix))
>             (goto-char (point-min)) (forward-line (1- line))
>             (put-text-property (point) (+ (point) len) 'display look)))))
>     (widen)))

I like this version; looks really nice.

-- 
YYR




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

end of thread, other threads:[~2012-01-19 21:13 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-01-18  2:42 Customize citation character Philipp Haselwarter
2012-01-18  3:57 ` Katsumi Yamaoka
2012-01-18  7:31   ` Reiner Steib
2012-01-18 17:58     ` Yagnesh Raghava Yakkala
2012-01-18 18:15       ` Yagnesh Raghava Yakkala
2012-01-19 19:24         ` Philipp Haselwarter
2012-01-19 21:13           ` Yagnesh Raghava Yakkala
2012-01-18  6:17 ` Martin
2012-01-18  8:48 ` Eric S Fraga
2012-01-18 10:06   ` Eric S Fraga

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