diff options
Diffstat (limited to 'lisp/net')
| -rw-r--r-- | lisp/net/eww.el | 70 | ||||
| -rw-r--r-- | lisp/net/imap.el | 18 | ||||
| -rw-r--r-- | lisp/net/shr.el | 29 |
3 files changed, 65 insertions, 52 deletions
diff --git a/lisp/net/eww.el b/lisp/net/eww.el index bc74a0d31d2..e8b8c63addb 100644 --- a/lisp/net/eww.el +++ b/lisp/net/eww.el @@ -275,6 +275,10 @@ word(s) will be searched for via `eww-search-prefix'." (setq url (concat url "/")))) (setq url (concat eww-search-prefix (replace-regexp-in-string " " "+" url)))))) + (pop-to-buffer-same-window + (if (eq major-mode 'eww-mode) + (current-buffer) + (get-buffer-create "*eww*"))) (eww-setup-buffer) ;; Check whether the domain only uses "Highly Restricted" Unicode ;; IDNA characters. If not, transform to punycode to indicate that @@ -557,7 +561,7 @@ Currently this means either text/html or application/xhtml+xml." (declare-function mailcap-view-mime "mailcap" (type)) (defun eww-display-pdf () (let ((data (buffer-substring (point) (point-max)))) - (switch-to-buffer (get-buffer-create "*eww pdf*")) + (pop-to-buffer-same-window (get-buffer-create "*eww pdf*")) (let ((coding-system-for-write 'raw-text) (inhibit-read-only t)) (erase-buffer) @@ -566,7 +570,6 @@ Currently this means either text/html or application/xhtml+xml." (goto-char (point-min))) (defun eww-setup-buffer () - (switch-to-buffer (get-buffer-create "*eww*")) (when (or (plist-get eww-data :url) (plist-get eww-data :dom)) (eww-save-history)) @@ -759,9 +762,9 @@ the like." ;;;###autoload (defun eww-browse-url (url &optional new-window) - (cond (new-window - (switch-to-buffer (generate-new-buffer "*eww*")) - (eww-mode))) + (when new-window + (pop-to-buffer-same-window (generate-new-buffer "*eww*")) + (eww-mode)) (eww url)) (defun eww-back-url () @@ -933,6 +936,7 @@ network, but just re-display the HTML already fetched." (let ((eww-form (list (cons :method (dom-attr dom 'method)) (cons :action (dom-attr dom 'action)))) (start (point))) + (insert "\n") (shr-ensure-paragraph) (shr-generic dom) (unless (bolp) @@ -1042,6 +1046,7 @@ See URL `https://developer.mozilla.org/en-US/docs/Web/HTML/Element/Input'.") (1- end))))) (let* ((form (get-text-property pos 'eww-form)) (properties (text-properties-at pos)) + (buffer-undo-list t) (inhibit-read-only t) (length (- end beg replace-length)) (type (plist-get form :type))) @@ -1056,19 +1061,19 @@ See URL `https://developer.mozilla.org/en-US/docs/Web/HTML/Element/Input'.") (1- (line-end-position)) (eww-end-of-field))) (while (and (> length 0) - (eql (following-char) ? )) + (eql (char-after (1- (point))) ? )) (delete-region (1- (point)) (point)) (cl-decf length)))) ((< length 0) ;; Add padding. (save-excursion - (goto-char (1- end)) + (goto-char end) (goto-char (if (equal type "textarea") (1- (line-end-position)) (1+ (eww-end-of-field)))) (let ((start (point))) - (insert (make-string (abs length) ? )) + (insert (make-string (abs length) ? )) (set-text-properties start (point) properties)) (goto-char (1- end))))) (set-text-properties (plist-get form :start) (plist-get form :end) @@ -1082,8 +1087,9 @@ See URL `https://developer.mozilla.org/en-US/docs/Web/HTML/Element/Input'.") (when (equal type "password") ;; Display passwords as asterisks. (let ((start (eww-beginning-of-field))) - (put-text-property start (+ start (length value)) - 'display (make-string (length value) ?*))))))))) + (put-text-property + start (+ start (length value)) + 'display (make-string (length value) ?*))))))))) (defun eww-tag-textarea (dom) (let ((start (point)) @@ -1145,7 +1151,9 @@ See URL `https://developer.mozilla.org/en-US/docs/Web/HTML/Element/Input'.") (t (eww-form-text dom))) (unless (= start (point)) - (put-text-property start (1+ start) 'help-echo "Input field")))) + (put-text-property start (1+ start) 'help-echo "Input field") + ;; Mark this as an element we can TAB to. + (put-text-property start (1+ start) 'shr-url dom)))) (defun eww-tag-select (dom) (shr-ensure-paragraph) @@ -1476,21 +1484,21 @@ Differences in #targets are ignored." string))) (defun eww-make-unique-file-name (file directory) - (cond - ((zerop (length file)) - (setq file "!")) - ((string-match "\\`[.]" file) - (setq file (concat "!" file)))) - (let ((count 1) - (stem file) - (suffix "")) - (when (string-match "\\`\\(.*\\)\\([.][^.]+\\)" file) - (setq stem (match-string 1) - suffix (match-string 2))) - (while (file-exists-p (expand-file-name file directory)) - (setq file (format "%s(%d)%s" stem count suffix)) - (setq count (1+ count))) - (expand-file-name file directory))) + (cond + ((zerop (length file)) + (setq file "!")) + ((string-match "\\`[.]" file) + (setq file (concat "!" file)))) + (let ((count 1) + (stem file) + (suffix "")) + (when (string-match "\\`\\(.*\\)\\([.][^.]+\\)" file) + (setq stem (match-string 1 file) + suffix (match-string 2))) + (while (file-exists-p (expand-file-name file directory)) + (setq file (format "%s(%d)%s" stem count suffix)) + (setq count (1+ count))) + (expand-file-name file directory))) (defun eww-set-character-encoding (charset) "Set character encoding to CHARSET. @@ -1576,8 +1584,8 @@ If CHARSET is nil then use UTF-8." (defun eww-list-bookmarks () "Display the bookmarks." (interactive) - (eww-bookmark-prepare) - (pop-to-buffer "*eww bookmarks*")) + (pop-to-buffer "*eww bookmarks*") + (eww-bookmark-prepare)) (defun eww-bookmark-prepare () (eww-read-bookmarks) @@ -1764,7 +1772,7 @@ If CHARSET is nil then use UTF-8." (let ((buffer eww-current-buffer)) (quit-window) (when buffer - (switch-to-buffer buffer))) + (pop-to-buffer-same-window buffer))) (eww-restore-history history))) (defvar eww-history-mode-map @@ -1845,7 +1853,7 @@ If CHARSET is nil then use UTF-8." (unless buffer (error "No buffer on current line")) (quit-window) - (switch-to-buffer buffer))) + (pop-to-buffer-same-window buffer))) (defun eww-buffer-show () "Display buffer under point in eww buffer list." @@ -1854,7 +1862,7 @@ If CHARSET is nil then use UTF-8." (unless buffer (error "No buffer on current line")) (other-window -1) - (switch-to-buffer buffer) + (pop-to-buffer-same-window buffer) (other-window 1))) (defun eww-buffer-show-next () diff --git a/lisp/net/imap.el b/lisp/net/imap.el index 5c5ed868172..e5a14d75dee 100644 --- a/lisp/net/imap.el +++ b/lisp/net/imap.el @@ -747,13 +747,19 @@ sure of changing the value of `foo'." :capability-command "1 CAPABILITY\r\n" :always-query-capabilities t :end-of-command "\r\n" - :success " OK " + :success "^1 OK " :starttls-function - (lambda (capabilities) - (when (string-match-p "STARTTLS" capabilities) - "1 STARTTLS\r\n")))) - (done (and process - (memq (process-status process) '(open run))))) + #'(lambda (capabilities) + (when (string-match-p "STARTTLS" capabilities) + "1 STARTTLS\r\n")))) + done) + (when process + (imap-log buffer) + (when (memq (process-status process) '(open run)) + (setq done process) + (with-current-buffer buffer + (goto-char (point-min)) + (imap-parse-greeting)))) (message "imap: Connecting with STARTTLS...%s" (if done "done" "failed")) done)) diff --git a/lisp/net/shr.el b/lisp/net/shr.el index c5de34a4ac5..a8ba2845aa2 100644 --- a/lisp/net/shr.el +++ b/lisp/net/shr.el @@ -981,7 +981,7 @@ element is the data blob and the second element is the content-type." (image-animated-p image)))) (image-animate image nil 60))) image) - (insert alt))) + (insert (or alt "")))) (defun shr-rescale-image (data &optional content-type) "Rescale DATA, if too big, to fit the current buffer." @@ -1426,9 +1426,7 @@ The preference is a float determined from `shr-prefer-media-type'." (and shr-blocked-images (string-match shr-blocked-images url))) (setq shr-start (point)) - (if (> (string-width alt) 8) - (shr-insert (truncate-string-to-width alt 8)) - (shr-insert alt))) + (shr-insert alt)) ((and (not shr-ignore-cache) (url-is-cached (shr-encode-url url))) (funcall shr-put-image-function (shr-get-image-data url) alt)) @@ -1771,17 +1769,18 @@ The preference is a float determined from `shr-prefer-media-type'." align))) (dolist (line lines) (end-of-line) - (let ((start (point))) - (insert - line - (propertize " " - 'display `(space :align-to (,pixel-align)) - 'face (and (> (length line) 0) - (shr-face-background - (get-text-property - (1- (length line)) 'face line))) - 'shr-table-indent shr-table-id) - shr-table-vertical-line) + (let ((start (point)) + (background (and (> (length line) 0) + (shr-face-background + (get-text-property + (1- (length line)) 'face line)))) + (space (propertize + " " + 'display `(space :align-to (,pixel-align)) + 'shr-table-indent shr-table-id))) + (when background + (setq space (propertize space 'face background))) + (insert line space shr-table-vertical-line) (shr-colorize-region start (1- (point)) (nth 5 column) (nth 6 column))) (forward-line 1)) |
