[Date Prev][Date Next][Thread Prev][][Date Index][Thread Index]

Re: [PATCH] Add functionality for editing textareas in Org-mode



Thorsten Jolitz <tjolitz@xxxxxxxxx> writes:

Hi List, 

here is patch for my last patch that fixes the conditional activation of
keymaps for w3m-form-input-textarea-mode (thx to Stefan Monnier for his
help on this). 
From 4242b5962ece9720e665ff080704beaa74c96230 Mon Sep 17 00:00:00 2001
From: tj <tj@xxxxxxxxxxxxxx>
Date: Sat, 5 Oct 2013 09:42:24 +0200
Subject: [PATCH] Conditional activation of keymap for
 w3m-form-input-textarea-mode fixed.

---
 w3m-form.el | 32 +++++++++++++-------------------
 1 file changed, 13 insertions(+), 19 deletions(-)

diff --git a/w3m-form.el b/w3m-form.el
index 6abd8e4..ca79be1 100644
--- a/w3m-form.el
+++ b/w3m-form.el
@@ -1121,16 +1121,16 @@ character."
 	    lines
 	    (get-text-property (point) 'w3m-form-readonly)))))
 
-(defvar w3m-form-input-textarea-default-map nil)
-(unless w3m-form-input-textarea-default-map
-  (setq w3m-form-input-textarea-default-map (make-sparse-keymap))
-  (define-key w3m-form-input-textarea-default-map "\C-c\C-c"
+(defvar w3m-form-input-textarea-mode-map nil)
+(unless w3m-form-input-textarea-mode-map
+  (setq w3m-form-input-textarea-mode-map (make-sparse-keymap))
+  (define-key w3m-form-input-textarea-mode-map "\C-c\C-c"
     'w3m-form-input-textarea-set)
-  (define-key w3m-form-input-textarea-default-map "\C-c\C-q"
+  (define-key w3m-form-input-textarea-mode-map "\C-c\C-q"
     'w3m-form-input-textarea-exit)
-  (define-key w3m-form-input-textarea-default-map "\C-c\C-k"
+  (define-key w3m-form-input-textarea-mode-map "\C-c\C-k"
     'w3m-form-input-textarea-exit)
-  (define-key w3m-form-input-textarea-default-map "\C-c\C-s"
+  (define-key w3m-form-input-textarea-mode-map "\C-c\C-s"
     'w3m-form-input-textarea-save))
 
 (defvar w3m-form-input-textarea-org-mode-map nil)
@@ -1259,21 +1259,16 @@ Minor mode to edit form textareas of w3m.
 	      (if arg
 		  (> (prefix-numeric-value arg) 0)
 		(not w3m-form-input-textarea-mode)))
-    (run-hooks 'w3m-form-input-textarea-mode-hook)))
-
+    (run-hooks 'w3m-form-input-textarea-mode-hook))
+  (when (eq major-mode 'org-mode)
+     (add-to-list 'minor-mode-overriding-map-alist
+         (cons 'w3m-form-input-textarea-mode
+               w3m-form-input-textarea-org-mode-map))))
 
 (defvar w3m-form-textarea-use-org-mode-p nil
   "Use org-mode for editing textareas when non-nil")
 
-(defun w3m-form-input-textarea-buffer-set-keymap ()
-  "Set keymap conditional on `w3m-form-textarea-use-org-mode-p'"
-  (if w3m-form-textarea-use-org-mode-p
-      (setq w3m-form-input-textarea-mode-map
-            w3m-form-input-textarea-org-mode-map)
-      (setq w3m-form-input-textarea-mode-map
-            w3m-form-input-textarea-default-map)))
-
-(defun w3m-form-toggle-textarea-major-mode (&optional arg)
+(defun w3m-form-textarea-toggle-major-mode (&optional arg)
   "Toggle editing textareas in Org-mode.
 When off, textareas are edited in text-mode, otherwise in
 org-mode. With prefix argument ARG, use org-mode if ARG is
@@ -1283,7 +1278,6 @@ positive, otherwise text-mode."
         (if (null arg)
             (not w3m-form-textarea-use-org-mode-p)
           (> (prefix-numeric-value arg) 0)))
-  (w3m-form-input-textarea-buffer-set-keymap)
   (message "Edit textarea in Org-mode %s"
            (if w3m-form-textarea-use-org-mode-p "enabled" "disabled")))
 
-- 
1.8.2.3

Attachment: w3m-form.el
Description: Modified w3m-form.el

-- 
cheers,
Thorsten