Commit 266c63b5 authored by Albert Krewinkel's avatar Albert Krewinkel Committed by Katsumi Yamaoka
Browse files

lisp/gnus/sieve.el: Fix handling of PORT parameter, quitting

parent e4568f3b
2013-06-10 Lars Magne Ingebrigtsen <>
* eww.el: Don't require cl-lib.
* eww.el: Start writing a new, tiny web browser.
(eww-previous-url): New command.
(eww-quit): New command.
2013-06-10 Albert Krewinkel <>
* sieve.el: Put point at beginning of buffer when viewing a script.
(sieve-open-server): respect the PORT parameter. Show the correct port
number in sieve-buffer's header. Fixed code to also work with a string
as port specifier. Properly close the connection on pressing 'q'. Make
sieve-manage-quit close the connection and process buffer. Also, remove
duplicate keybinding for 'q'.
2013-06-10 Roy Hashimoto <> (tiny change)
* mm-view.el (mm-pkcs7-signed-magic): Allow newline in the regexp and
;;; eww.el --- Emacs Web Wowser
;; Copyright (C) 2013 Free Software Foundation, Inc.
;; Author: Lars Magne Ingebrigtsen <>
;; Keywords: html
;; This file is part of GNU Emacs.
;; GNU Emacs is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs. If not, see <>.
;;; Commentary:
;;; Code:
(eval-when-compile (require 'cl))
(require 'shr)
(require 'url)
(defvar eww-current-url nil)
(defvar eww-history nil)
(defun eww (url)
"Fetch URL and render the page."
(interactive "sUrl: ")
(url-retrieve url 'eww-render (list url)))
(defun eww-render (status url &optional point)
(let* ((headers (eww-parse-headers))
(or (cdr (assoc "content-type" headers))
(charset (intern
(or (cdr (assq 'charset (cdr content-type)))
(data-buffer (current-buffer)))
((equal (car content-type) "text/html")
(eww-display-html charset url))
((string-match "^image/" (car content-type))
(eww-display-raw charset)))
(when point
(goto-char point)))
(kill-buffer data-buffer))))
(defun eww-parse-headers ()
(let ((headers nil))
(while (and (not (eobp))
(not (eolp)))
(when (looking-at "\\([^:]+\\): *\\(.*\\)")
(push (cons (downcase (match-string 1))
(match-string 2))
(forward-line 1))
(unless (eobp)
(forward-line 1))
(defun eww-display-html (charset url)
(unless (eq charset 'utf8)
(decode-coding-region (point) (point-max) charset))
(let ((document
'base (list (cons 'href url))
(libxml-parse-html-region (point) (point-max)))))
(setq eww-current-url url)
(let ((inhibit-read-only t))
(shr-insert-document document))
(goto-char (point-min))))
(defun eww-display-raw (charset)
(let ((data (buffer-substring (point) (point-max))))
(let ((inhibit-read-only t))
(insert data))
(goto-char (point-min))))
(defun eww-display-image ()
(let ((data (buffer-substring (point) (point-max))))
(let ((inhibit-read-only t))
(shr-put-image data nil))
(goto-char (point-min))))
(defun eww-setup-buffer ()
(pop-to-buffer (get-buffer-create "*eww*"))
(let ((inhibit-read-only t))
(defvar eww-mode-map
(let ((map (make-sparse-keymap)))
(suppress-keymap map)
(define-key map "q" 'eww-quit)
(define-key map [tab] 'widget-forward)
(define-key map [backtab] 'widget-backward)
(define-key map [delete] 'scroll-down-command)
(define-key map "\177" 'scroll-down-command)
(define-key map " " 'scroll-up-command)
(define-key map "p" 'eww-previous-url)
;;(define-key map "n" 'eww-next-url)
(defun eww-mode ()
"Mode for browsing the web.
(setq major-mode 'eww-mode
mode-name "eww")
(set (make-local-variable 'eww-current-url) 'author)
(set (make-local-variable 'browse-url-browser-function) 'eww-browse-url)
(setq buffer-read-only t)
(use-local-map eww-mode-map))
(defun eww-browse-url (url &optional new-window)
(push (list eww-current-url (point))
(eww url))
(defun eww-quit ()
"Exit the Emacs Web Wowser."
(setq eww-history nil)
(kill-buffer (current-buffer)))
(defun eww-previous-url ()
"Go to the previously displayed page."
(when (zerop (length eww-history))
(error "No previous page"))
(let ((prev (pop eww-history)))
(url-retrieve (car prev) 'eww-render (list (car prev) (cadr prev)))))
(provide 'eww)
;;; eww.el ends here
......@@ -945,7 +945,8 @@ ones, in case fg and bg are nil."
(defun shr-tag-base (cont)
(setq shr-base (cdr (assq :href cont))))
(setq shr-base (cdr (assq :href cont)))
(shr-generic cont))
(defun shr-tag-a (cont)
(let ((url (cdr (assq :href cont)))
......@@ -109,7 +109,6 @@ require \"fileinto\";
;; various
(define-key map "?" 'sieve-help)
(define-key map "h" 'sieve-help)
(define-key map "q" 'kill-buffer)
;; activating
(define-key map "m" 'sieve-activate)
(define-key map "u" 'sieve-deactivate)
......@@ -152,6 +151,8 @@ require \"fileinto\";
(defun sieve-manage-quit ()
(sieve-manage-close sieve-manage-buffer)
(kill-buffer sieve-manage-buffer)
(kill-buffer (current-buffer)))
(defun sieve-activate (&optional pos)
......@@ -206,6 +207,7 @@ require \"fileinto\";
(insert sieve-template))
(setq sieve-buffer-script-name name)
"Press \\[sieve-upload] to upload script to server."))))
......@@ -256,10 +258,9 @@ Used to bracket operations which move point in the sieve-buffer."
(setq buffer-read-only nil)
(insert "\
Server : " server ":" (or port sieve-manage-default-port) "
(let* ((port (or port sieve-manage-default-port))
(header (format "Server : %s:%s\n\n" server port)))
(insert header))
(set (make-local-variable 'sieve-buffer-header-end)
......@@ -305,7 +306,7 @@ Server : " server ":" (or port sieve-manage-default-port) "
(or ;; open server
(set (make-local-variable 'sieve-manage-buffer)
(sieve-manage-open server))
(sieve-manage-open server port))
(error "Error opening server %s" server))
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment