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

Re: form submitでのnew-session表示

From: Tsuyoshi CHO <tsuyoshi_cho@xxxxxxxxx> さん曰く
Subject: [emacs-w3m:08964] form submitでのnew-session表示
Message-ID: <u64d5eyob.wl%tsuyoshi_cho@xxxxxxxxxxx>
Date: Fri, 24 Nov 2006 22:56:04 +0900

> 以下で話しがあったのですが、
> http://slashdot.jp/~cheekcat/journal/383567


> submitでのページ遷移の先を別バッファにしてみよう。といろいろやってみました。
> が、


(defvar w3m-form-submit-new-session nil)

(defun w3m-view-this-url-new-session ()
  "Display the page of the link under point in a new session.
If the region is active, use the `w3m-open-all-links-in-new-session'
command instead."
  (if (w3m-region-active-p)
      (call-interactively 'w3m-open-all-links-in-new-session)
    (let ((w3m-form-submit-new-session t))
      (w3m-view-this-url nil t))))

(defun w3m-submit-form (&optional new-session)
  "Submit the form at point."
  (let ((submit (w3m-submit)))
    (if (and submit
	     (w3m-url-valid w3m-current-url))
	(let ((w3m-form-submit-new-session new-session))
	  (eval submit))
      (w3m-message "Can't submit form at this point"))))

(defun w3m-form-submit-goto-url (&rest args)
  (apply (if w3m-form-submit-new-session

(defun w3m-form-submit (form &optional id name value)
  (if (w3m-anchor (point))
      ;; cf SA17565
      (w3m-form-submit-goto-url (w3m-anchor (point)))
    (when (and id name
	       (> (length name) 0))
      (w3m-form-put form id name value))
    (let* ((orig-url w3m-current-url)
	   (url (or (w3m-form-action form)
		    (if (string-match "\\?" w3m-current-url)
			(substring w3m-current-url 0 (match-beginning 0))
      (setq w3m-form-textarea-post-files
	    (w3m-form-submit-get-textarea-files form))
      (cond ((and (not (string= url orig-url))
		  (string-match "^https://" orig-url)
		  (string-match "^http://" url)
		  (not (y-or-n-p (format "Send POST data to '%s'?" url))))
	    ((or (eq 'post (w3m-form-method form))
		 ;; While some sites, e.g., emacswiki.org, specify the
		 ;; `get' method for the enctype `multipart/form-data',
		 ;; we use the `post' method according to the proposal
		 ;; of RFC2070.
		 (eq 'multipart/form-data (w3m-form-enctype form)))
	     (w3m-form-submit-goto-url url 'reload nil
				       (w3m-form-make-form-data form)
	    ((eq 'get (w3m-form-method form))
	      (concat url "?" (w3m-form-make-form-data form))))
	     (w3m-message "This form's method has not been supported: %s"
			  (let (print-level print-length)
			    (prin1-to-string (w3m-form-method form)))))))))

白井秀行 (mailto:shirai@xxxxxxxxxxx)