--- /dev/null
+Return-Path: <too@guru-group.fi>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+ by olra.theworths.org (Postfix) with ESMTP id B34B1431FCB\r
+ for <notmuch@notmuchmail.org>; Fri, 29 Jun 2012 12:05:47 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]\r
+ autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+ by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id a2liDA+L8Scg for <notmuch@notmuchmail.org>;\r
+ Fri, 29 Jun 2012 12:05:46 -0700 (PDT)\r
+Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34])\r
+ by olra.theworths.org (Postfix) with ESMTP id 1E314431FAF\r
+ for <notmuch@notmuchmail.org>; Fri, 29 Jun 2012 12:05:46 -0700 (PDT)\r
+Received: by guru.guru-group.fi (Postfix, from userid 501)\r
+ id 6D3DB1002A4; Fri, 29 Jun 2012 22:05:55 +0300 (EEST)\r
+From: Tomi Ollila <tomi.ollila@iki.fi>\r
+To: notmuch@notmuchmail.org\r
+Subject: [UGLY DFAFT PATCH] draft: emacs: custom variable to choose default\r
+ reply-to behaviour\r
+Date: Fri, 29 Jun 2012 22:05:53 +0300\r
+Message-Id: <1340996753-30258-1-git-send-email-tomi.ollila@iki.fi>\r
+X-Mailer: git-send-email 1.7.1\r
+In-Reply-To: <87y5n7z5aj.fsf@yoom.home.cworth.org>\r
+References: <87y5n7z5aj.fsf@yoom.home.cworth.org>\r
+Cc: Tomi Ollila <tomi.ollila@iki.fi>\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Fri, 29 Jun 2012 19:05:47 -0000\r
+\r
+This is one draft solution to provide an implementation described in\r
+id:"87y5n7z5aj.fsf@yoom.home.cworth.org"\r
+\r
+Comments how things could be done better (or totally different way)\r
+are welcome -- and specially, if you are better than me in elisp\r
+(which you probably are) reuse any code freely in your implementation...\r
+\r
+There are some things missing (like declare-functions (and specially, one\r
+`custom-set`) and new code is not necessarily located at the most suitable\r
+places -- for now the changes are "localized" to 2 places.\r
+\r
+This implementation uses custom variable and based on that the 4 keybindings\r
+are set -- if custom variable is nil then bindings point to the setting\r
+interface functions. Currenlty after later changes outside of those setting\r
+functions does not change bindings -- in the future using\r
+customize-save-variable that will change bindings -- but always when using\r
+setq/set to change the (custom) variable will not change the bindings (so\r
+the variable can be made out-of-sync with the bindings -- if that matters).\r
+---\r
+ emacs/notmuch-show.el | 58 +++++++++++++++++++++++++++++++++++++++++++++++-\r
+ emacs/notmuch.el | 23 +++++++++++++++++-\r
+ 2 files changed, 77 insertions(+), 4 deletions(-)\r
+\r
+diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
+index 4349836..10eb75d 100644\r
+--- a/emacs/notmuch-show.el\r
++++ b/emacs/notmuch-show.el\r
+@@ -1134,6 +1134,61 @@ reset based on the original query."\r
+ "Submap for stash commands")\r
+ (fset 'notmuch-show-stash-map notmuch-show-stash-map)\r
+ \r
++;;; draft code ;;;\r
++(defcustom notmuch-reply-to-default nil\r
++ "Doc string (i.e. not documented yet)"\r
++ :type '(choice (const :tag "reply to all" 'all)\r
++ (const :tag "reply to sender" 'sender))\r
++ ;;:custom-set 'set-default-and-keybinding\r
++ :group 'notmuch-send)\r
++\r
++(defun notmuch-choose-reply-keybindings ()\r
++ (interactive)\r
++ (defun ia () (interactive) (insert "a") (exit-minibuffer))\r
++ (defun is () (interactive) (insert "s") (exit-minibuffer))\r
++ (defun iA () (interactive) (insert "A") (exit-minibuffer))\r
++ (defun iS () (interactive) (insert "S") (exit-minibuffer))\r
++ (let ((map (make-keymap)))\r
++ (suppress-keymap map t)\r
++ ;;(define-key map "?" 'helep)\r
++ (define-key map "a" 'ia)\r
++ (define-key map "s" 'is)\r
++ (define-key map "A" 'iA)\r
++ (define-key map "S" 'iS)\r
++ (save-excursion\r
++ (let ((val (read-from-minibuffer\r
++ "Reply to all or sender only? [asAS?]:" nil map)))\r
++ (cond ((string= val "a") t)\r
++ ((string= val "s") nil)\r
++ ((string= val "A")\r
++ (customize-save-variable 'notmuch-reply-to-default 'all)\r
++ (notmuch-show-set-reply-keybindings) ;; not needed when ...\r
++ (notmuch-search-set-reply-keybindings) t) ;; custom-set in use.\r
++ ((string= val "S")\r
++ (customize-save-variable 'notmuch-reply-to-default 'sender)\r
++ (notmuch-show-set-reply-keybindings) ;; not needed when ...\r
++ (notmuch-search-set-reply-keybindings) nil) ;; custom-set in use\r
++ )))))\r
++\r
++(defun notmuch-show-choose-reply-keybindings ()\r
++ (interactive)\r
++ (if (notmuch-choose-reply-keybindings)\r
++ (notmuch-show-reply)\r
++ (notmuch-show-reply-sender)))\r
++\r
++(defun notmuch-show-set-reply-keybindings (&optional map)\r
++ (unless map\r
++ (set 'map notmuch-show-mode-map))\r
++ (cond ((eq notmuch-reply-to-default 'all)\r
++ (define-key map "r" 'notmuch-show-reply)\r
++ (define-key map "R" 'notmuch-show-reply-sender))\r
++ ((eq notmuch-reply-to-default 'sender)\r
++ (define-key map "r" 'notmuch-show-reply-sender)\r
++ (define-key map "R" 'notmuch-show-reply))\r
++ (t\r
++ (define-key map "r" 'notmuch-show-choose-reply-keybindings)\r
++ (define-key map "R" 'notmuch-show-choose-reply-keybindings))))\r
++\r
+ (defvar notmuch-show-mode-map\r
+ (let ((map (make-sparse-keymap)))\r
+ (define-key map "?" 'notmuch-help)\r
+@@ -1145,8 +1200,6 @@ reset based on the original query."\r
+ (define-key map "s" 'notmuch-search)\r
+ (define-key map "m" 'notmuch-mua-new-mail)\r
+ (define-key map "f" 'notmuch-show-forward-message)\r
+- (define-key map "r" 'notmuch-show-reply-sender)\r
+- (define-key map "R" 'notmuch-show-reply)\r
+ (define-key map "|" 'notmuch-show-pipe-message)\r
+ (define-key map "w" 'notmuch-show-save-attachments)\r
+ (define-key map "V" 'notmuch-show-view-raw-message)\r
+@@ -1174,6 +1227,7 @@ reset based on the original query."\r
+ (define-key map "$" 'notmuch-show-toggle-process-crypto)\r
+ (define-key map "<" 'notmuch-show-toggle-thread-indentation)\r
+ (define-key map "t" 'toggle-truncate-lines)\r
++ (notmuch-show-set-reply-keybindings map)\r
+ map)\r
+ "Keymap for \"notmuch show\" buffers.")\r
+ (fset 'notmuch-show-mode-map notmuch-show-mode-map)\r
+diff --git a/emacs/notmuch.el b/emacs/notmuch.el\r
+index c6236db..a95e191 100644\r
+--- a/emacs/notmuch.el\r
++++ b/emacs/notmuch.el\r
+@@ -203,6 +203,26 @@ For a mouse binding, return nil."\r
+ :group 'notmuch-search\r
+ :group 'notmuch-hooks)\r
+ \r
++;;; draft code ;;;\r
++(defun notmuch-search-choose-reply-keybindings ()\r
++ (interactive)\r
++ (if (notmuch-choose-reply-keybindings)\r
++ (notmuch-search-reply-to-thread)\r
++ (notmuch-search-reply-to-thread-sender)))\r
++\r
++(defun notmuch-search-set-reply-keybindings (&optional map)\r
++ (unless map\r
++ (set 'map notmuch-search-mode-map))\r
++ (cond ((eq notmuch-reply-to-default 'all)\r
++ (define-key map "r" 'notmuch-search-reply-to-thread)\r
++ (define-key map "R" 'notmuch-search-reply-to-thread-sender))\r
++ ((eq notmuch-reply-to-default 'sender)\r
++ (define-key map "r" 'notmuch-search-reply-to-thread-sender)\r
++ (define-key map "R" 'notmuch-search-reply-to-thread))\r
++ (t\r
++ (define-key map "r" 'notmuch-search-choose-reply-keybindings)\r
++ (define-key map "R" 'notmuch-search-choose-reply-keybindings))))\r
++\r
+ (defvar notmuch-search-mode-map\r
+ (let ((map (make-sparse-keymap)))\r
+ (define-key map "?" 'notmuch-help)\r
+@@ -215,8 +235,6 @@ For a mouse binding, return nil."\r
+ (define-key map ">" 'notmuch-search-last-thread)\r
+ (define-key map "p" 'notmuch-search-previous-thread)\r
+ (define-key map "n" 'notmuch-search-next-thread)\r
+- (define-key map "r" 'notmuch-search-reply-to-thread-sender)\r
+- (define-key map "R" 'notmuch-search-reply-to-thread)\r
+ (define-key map "m" 'notmuch-mua-new-mail)\r
+ (define-key map "s" 'notmuch-search)\r
+ (define-key map "o" 'notmuch-search-toggle-order)\r
+@@ -231,6 +249,7 @@ For a mouse binding, return nil."\r
+ (define-key map "-" 'notmuch-search-remove-tag)\r
+ (define-key map "+" 'notmuch-search-add-tag)\r
+ (define-key map (kbd "RET") 'notmuch-search-show-thread)\r
++ (notmuch-search-set-reply-keybindings map)\r
+ map)\r
+ "Keymap for \"notmuch search\" buffers.")\r
+ (fset 'notmuch-search-mode-map notmuch-search-mode-map)\r
+-- \r
+1.7.1\r
+\r