[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: terminating form input by `C-c C-c'
- From: Katsumi Yamaoka <yamaoka@xxxxxxx>
- Date: Thu, 05 Feb 2009 19:19:43 +0900
- X-ml-name: emacs-w3m
- X-mail-count: 10675
- References: <b4mtz7apx6g.fsf@xxxxxxx> <87eiyepuaj.fsf@xxxxxxxxxxxxxxxx> <20090204.155506.140687061.shirai.hideyuki@xxxxxxxxxxx>
>>>>> In [emacs-w3m : No.10673] 白井さん wrote:
> From: Naohiro Aota <naota@xxxxxxxxx> さん曰く
>> ぼくは textarea と同じつもりで C-c C-c している(と思う)ので、 submit まで
>> 動かすとタイトルだけ入力して本文なしの日記が投稿されたりしちゃいそうです ^^;
> google しか想定していませんでした。提案取り下げ (__)
じゃあ google だけはそうする、とか。
url が、ある regexp にマッチする場合だけ `C-c C-c' でいきなり
submit するというのを作ってみました。でも場合によって動作が異な
るのは、かえって混乱するかもしれないですね。しばらく使ってみます。
(XEmacs では (this-command-keys) の戻り値が string ではないので
このままでは動きません。)
--- w3m-form.el~ 2009-01-04 21:39:55 +0000
+++ w3m-form.el 2009-02-05 10:18:30 +0000
@@ -960,19 +960,41 @@
(prog1 (point)
(goto-char p))))
+(defvar w3m-form-input-map
+ (let ((keymap (make-sparse-keymap)))
+ (define-key keymap "\C-c\C-c" 'exit-minibuffer)
+ (set-keymap-parent keymap minibuffer-local-map)
+ keymap)
+ "*Keymap that `w3m-form-input' uses in the minibuffer.")
+
+(defcustom w3m-form-immediate-submit-url
+ "\\`http://www\\.google\\.[a-z]+\\(?:\\.[a-z]+\\)?\\(?:\\'\\|/\\)"
+ "Regexp matching url in which the form is immediately submitted.
+When terminating the form input by the `C-c C-c' key, the form will be
+submitted immediately if the url currently visited matches this regexp.
+Nil matches no url."
+ :group 'w3m
+ :type '(radio (const nil) regexp))
+
(defun w3m-form-input (form id name type width maxlength value)
(let ((fvalue (w3m-form-get form id)))
(if (get-text-property (point) 'w3m-form-readonly)
(message "READONLY %s: %s" (upcase type) fvalue)
(save-excursion
(let ((input (save-excursion
- (read-from-minibuffer (concat (upcase type) ": ") fvalue)))
+ (read-from-minibuffer (concat (upcase type) ": ")
+ fvalue w3m-form-input-map)))
(coding (w3m-form-get-coding-system (w3m-form-charlst form))))
(when (with-temp-buffer
(insert input)
(w3m-form-coding-system-accept-region-p nil nil coding))
(w3m-form-put form id name input)
- (w3m-form-replace input)))))))
+ (w3m-form-replace input)
+ (if (and (equal (this-command-keys) "\C-c\C-c")
+ w3m-form-immediate-submit-url
+ (string-match w3m-form-immediate-submit-url
+ w3m-current-url))
+ (w3m-submit-form))))))))
(defun w3m-form-input-password (form id name)
(if (get-text-property (point) 'w3m-form-readonly)