From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/76967 Path: news.gmane.org!not-for-mail From: Antoine Levitt Newsgroups: gmane.emacs.gnus.general Subject: Re: Position of point in reply-with-original Date: Sat, 19 Feb 2011 16:13:29 +0100 Message-ID: <8762sg5a7a.fsf@gmail.com> References: <87tyglxjja.fsf@gmail.com> <87r5bpgk6p.fsf@ericabrahamsen.net> <87k4hhniw6.fsf@gmail.com> <87ipx1yqhz.fsf@topper.koldfront.dk> <87pqr8946o.fsf@gmail.com> <87pqr8py5g.fsf@topper.koldfront.dk> <87ipx07nws.fsf@gmail.com> <87d3n8loqz.fsf@lifelogs.com> <87vd10kx1a.fsf@gnus.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: dough.gmane.org 1298128497 30150 80.91.229.12 (19 Feb 2011 15:14:57 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sat, 19 Feb 2011 15:14:57 +0000 (UTC) To: ding@gnus.org Original-X-From: ding-owner+M25300@lists.math.uh.edu Sat Feb 19 16:14:53 2011 Return-path: Envelope-to: ding-account@gmane.org Original-Received: from util0.math.uh.edu ([129.7.128.18]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1PqoWK-0007sv-8k for ding-account@gmane.org; Sat, 19 Feb 2011 16:14:52 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.math.uh.edu) by util0.math.uh.edu with smtp (Exim 4.63) (envelope-from ) id 1PqoVM-00040V-58; Sat, 19 Feb 2011 09:13:52 -0600 Original-Received: from mx1.math.uh.edu ([129.7.128.32]) by util0.math.uh.edu with esmtps (TLSv1:AES256-SHA:256) (Exim 4.63) (envelope-from ) id 1PqoVJ-00040C-DD for ding@lists.math.uh.edu; Sat, 19 Feb 2011 09:13:49 -0600 Original-Received: from quimby.gnus.org ([80.91.231.51]) by mx1.math.uh.edu with esmtp (Exim 4.72) (envelope-from ) id 1PqoVE-0007nG-U2 for ding@lists.math.uh.edu; Sat, 19 Feb 2011 09:13:46 -0600 Original-Received: from lo.gmane.org ([80.91.229.12]) by quimby.gnus.org with esmtp (Exim 4.72) (envelope-from ) id 1PqoVC-0006NQ-NS for ding@gnus.org; Sat, 19 Feb 2011 16:13:42 +0100 Original-Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1PqoVC-0007HB-KP for ding@gnus.org; Sat, 19 Feb 2011 16:13:42 +0100 Original-Received: from uni14-1-82-233-220-106.fbx.proxad.net ([82.233.220.106]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 19 Feb 2011 16:13:42 +0100 Original-Received: from antoine.levitt by uni14-1-82-233-220-106.fbx.proxad.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 19 Feb 2011 16:13:42 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 264 Original-X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: uni14-1-82-233-220-106.fbx.proxad.net User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) Cancel-Lock: sha1:5H3pbGOhQS7eUHvrSmtll7ayMUM= X-Spam-Score: -1.0 (-) List-ID: Precedence: bulk Xref: news.gmane.org gmane.emacs.gnus.general:76967 Archived-At: --=-=-= Content-Type: text/plain 04/02/11 09:45, Lars Ingebrigtsen > > Given that this much is needed to get a satisfactory top posting format, > I don't think making the defvar->defcustom change would help much. > > Perhaps there should be a new meta-ish variable, say > > (defcustom message-cite-style nil > "The overall style to be used when yanking cited text. > Values are either `traditional' (cited text first), > `top-post' (cited text at the bottom), or nil (don't override the > individual message variables)." > :version "24.1" > :group 'message-various > :type '(choice (const :tag "None" :value nil) > (const :tag "Traditional" :value traditional) > (const :tag "Top-post" :value top-post))) > > This would bind the variables you mention above if set to `traditional' > or `top-post'. So I took a stab at this, and came up with the following patch. So, what it does: - The defvar -> defcustom change for message-cite-reply-above discussed before, with the prompt "are you sure you want to be evil?" removed, and allowing the choice in news posting - message-cite-reply-above -> message-cite-reply-position, which can be traditional (default), above or below - The new message-cite-style (apparently, you commited it in an unrelated commit, Lars: https://github.com/emacsmirror/emacs/commit/92a7a0fc1dcec08b923f267e53f1758507efd747) variable goes to the message-insertion group (that's where the other variables like this one are). Instead of taking symbol values, it takes either nil or a list of let-style (variable value) forms. - This variables/values pairs are enforced by a eval-let in message-yank-original, binding the variables in the function. If there's a more clever approach, please tell me. - message-cite-style presets for outlook, thunderbird and gmail (shamelessly ripped from Ted Zlatanov for the outlook one, roughly inferred for the other two) are available, allowing Gnus to impersonate other clients. Some of these are pretty ugly, though. The idea is that the user chooses between those styles or creates other ones, and then sets message-cite-style in gnus-posting-styles. It Works For Me (TM), and looks generic and simple enough to suit the needs of everybody. Here's the patch. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=cite_style.diff diff --git a/lisp/gnus/message.el b/lisp/gnus/message.el index 58daf1b..78da5d7 100644 --- a/lisp/gnus/message.el +++ b/lisp/gnus/message.el @@ -129,17 +129,6 @@ :group 'message-buffers :type '(choice function (const nil))) -(defcustom message-cite-style nil - "The overall style to be used when yanking cited text. -Values are either `traditional' (cited text first), -`top-post' (cited text at the bottom), or nil (don't override the -individual message variables)." - :version "24.1" - :group 'message-various - :type '(choice (const :tag "None" :value nil) - (const :tag "Traditional" :value traditional) - (const :tag "Top-post" :value top-post))) - (defcustom message-fcc-handler-function 'message-output "*A function called to save outgoing articles. This function will be called with the name of the file to store the @@ -1088,6 +1077,71 @@ needed." :link '(custom-manual "(message)Insertion Variables") :group 'message-insertion) +(defcustom message-cite-reply-position 'traditional + "*Where the reply should be positioned. +If `traditional', reply inline. +If `above', reply above quoted text. +If `below', reply below quoted text. + +Note: Many newsgroups frown upon nontraditional reply styles. You +probably want to set this variable only for specific groups, +e.g. using `gnus-posting-styles': + + (eval (set (make-local-variable 'message-cite-reply-above) 'above))" + :type '(choice (const :tag "Reply inline" 'traditional) + (const :tag "Reply above" 'above) + (const :tag "Reply below" 'below)) + :group 'message-insertion) + +(defcustom message-cite-style nil + "*The overall style to be used when yanking cited text. +Value is either `nil' (no variable overrides) or a let-style list +of pairs (VARIABLE VALUE) that will be bound in +`message-yank-original' to do the quoting. + +Presets to impersonate popular mail agents are found in the +message-cite-style-* variables. This variable is intended for +use in `gnus-posting-styles', such as: + + ((posting-from-work-p) (eval (set (make-local-variable 'message-cite-style) message-cite-style-outlook)))" + :version "24.1" + :group 'message-insertion + :type '(choice (const :tag "Do not override variables" :value nil) + (const :tag "MS Outlook" :value message-cite-style-outlook) + (const :tag "Mozilla Thunderbird" :value message-cite-style-thunderbird) + (const :tag "Gmail" :value message-cite-style-gmail) + (variable :tag "User-specified"))) + +(defconst message-cite-style-outlook + '((message-cite-function 'message-cite-original) + (message-citation-line-function 'message-insert-formatted-citation-line) + (message-cite-reply-position 'above) + (message-yank-prefix "") + (message-yank-cited-prefix "") + (message-yank-empty-prefix "") + (message-citation-line-format "\n\n-----------------------\nOn %a, %b %d %Y, %N wrote:\n")) + "Message citation style used by MS Outlook. Use with message-cite-style.") + +(defconst message-cite-style-thunderbird + '((message-cite-function 'message-cite-original) + (message-citation-line-function 'message-insert-formatted-citation-line) + (message-cite-reply-position 'above) + (message-yank-prefix "> ") + (message-yank-cited-prefix ">") + (message-yank-empty-prefix ">") + (message-citation-line-format "On %D %R %p, %N wrote:")) + "Message citation style used by Mozilla Thunderbird. Use with message-cite-style.") + +(defconst message-cite-style-gmail + '((message-cite-function 'message-cite-original) + (message-citation-line-function 'message-insert-formatted-citation-line) + (message-cite-reply-position 'above) + (message-yank-prefix " ") + (message-yank-cited-prefix " ") + (message-yank-empty-prefix " ") + (message-citation-line-format "On %e %B %Y %R, %f wrote:\n")) + "Message citation style used by Gmail. Use with message-cite-style.") + (defcustom message-distribution-function nil "*Function called to return a Distribution header." :group 'message-news @@ -3645,17 +3699,6 @@ To use this automatically, you may add this function to (while (re-search-forward citexp nil t) (replace-match (if remove "" "\n")))))) -(defvar message-cite-reply-above nil - "If non-nil, start own text above the quote. - -Note: Top posting is bad netiquette. Don't use it unless you -really must. You probably want to set variable only for specific -groups, e.g. using `gnus-posting-styles': - - (eval (set (make-local-variable 'message-cite-reply-above) t)) - -This variable has no effect in news postings.") - (defun message-yank-original (&optional arg) "Insert the message being replied to, if any. Puts point before the text and mark after. @@ -3669,49 +3712,49 @@ prefix, and don't delete any headers." (interactive "P") (let ((modified (buffer-modified-p)) body-text) - (when (and message-reply-buffer - message-cite-function) - (when message-cite-reply-above - (if (and (not (message-news-p)) - (or (eq message-cite-reply-above 'is-evil) - (y-or-n-p "\ -Top posting is bad netiquette. Please don't top post unless you really must. -Really top post? "))) + ;; eval the let forms contained in message-cite-style + (eval + `(let ,message-cite-style + (when (and message-reply-buffer + message-cite-function) + (when (equal message-cite-reply-position 'above) (save-excursion (setq body-text (buffer-substring (message-goto-body) (point-max))) - (delete-region (message-goto-body) (point-max))) - (set (make-local-variable 'message-cite-reply-above) nil))) - (if (bufferp message-reply-buffer) - (delete-windows-on message-reply-buffer t)) - (push-mark (save-excursion - (cond - ((bufferp message-reply-buffer) - (insert-buffer-substring message-reply-buffer)) - ((and (consp message-reply-buffer) - (functionp (car message-reply-buffer))) - (apply (car message-reply-buffer) - (cdr message-reply-buffer)))) - (unless (bolp) - (insert ?\n)) - (point))) - (unless arg - (funcall message-cite-function) - (unless (eq (char-before (mark t)) ?\n) - (let ((pt (point))) - (goto-char (mark t)) - (insert-before-markers ?\n) - (goto-char pt)))) - (when message-cite-reply-above - (message-goto-body) - (insert body-text) - (insert (if (bolp) "\n" "\n\n")) - (message-goto-body)) - ;; Add a `message-setup-very-last-hook' here? - ;; Add `gnus-article-highlight-citation' here? - (unless modified - (setq message-checksum (message-checksum)))))) + (delete-region (message-goto-body) (point-max)))) + (if (bufferp message-reply-buffer) + (delete-windows-on message-reply-buffer t)) + (push-mark (save-excursion + (cond + ((bufferp message-reply-buffer) + (insert-buffer-substring message-reply-buffer)) + ((and (consp message-reply-buffer) + (functionp (car message-reply-buffer))) + (apply (car message-reply-buffer) + (cdr message-reply-buffer)))) + (unless (bolp) + (insert ?\n)) + (point))) + (unless arg + (funcall message-cite-function) + (unless (eq (char-before (mark t)) ?\n) + (let ((pt (point))) + (goto-char (mark t)) + (insert-before-markers ?\n) + (goto-char pt)))) + (case message-cite-reply-position + ('above + (message-goto-body) + (insert body-text) + (insert (if (bolp) "\n" "\n\n")) + (message-goto-body)) + ('below + (message-goto-signature))) + ;; Add a `message-setup-very-last-hook' here? + ;; Add `gnus-article-highlight-citation' here? + (unless modified + (setq message-checksum (message-checksum)))))))) (defun message-yank-buffer (buffer) "Insert BUFFER into the current buffer and quote it." --=-=-=--