diff options
author | Xue Fuqiao <xfq.free@gmail.com> | 2013-12-26 06:27:00 +0800 |
---|---|---|
committer | Xue Fuqiao <xfq.free@gmail.com> | 2013-12-26 06:27:00 +0800 |
commit | 77bbf3713d459c45492e6daed68437edcf863a0c (patch) | |
tree | 0e2ea82f80e907cea52eb683a362504a3813a463 /lisp | |
parent | 3bc1e1880f232ccaea7c35a0c51bac61df9ac23c (diff) | |
parent | 83fa295c1236aba5a73d565082dcb58a32f3e446 (diff) | |
download | emacs-77bbf3713d459c45492e6daed68437edcf863a0c.tar.gz |
Merge from mainline.
Diffstat (limited to 'lisp')
-rw-r--r-- | lisp/ChangeLog | 54 | ||||
-rw-r--r-- | lisp/net/eww.el | 20 | ||||
-rw-r--r-- | lisp/net/shr.el | 34 | ||||
-rw-r--r-- | lisp/progmodes/python.el | 112 | ||||
-rw-r--r-- | lisp/window.el | 16 |
5 files changed, 163 insertions, 73 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 79244ec160c..45c2154db0e 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,57 @@ +2013-12-25 Lars Ingebrigtsen <larsi@gnus.org> + + * net/shr.el (shr-visit-file): Remove debugging function. + +2013-12-25 Fabián Ezequiel Gallina <fgallina@gnu.org> + + * progmodes/python.el: + (python-nav--lisp-forward-sexp): New function. + (python-nav--lisp-forward-sexp-safe): Use it. Rename from + python-nav-lisp-forward-sexp-safe. + (python-nav--forward-sexp): New argument SAFE allows switching + forward sexp movement behavior for parens. + (python-nav-forward-sexp): Throw errors on unterminated parens + (Bug#16191). + (python-nav-backward-sexp, python-nav-forward-sexp-safe) + (python-nav-backward-sexp-safe): New functions. + (python-shell-buffer-substring): Use + `python-nav-forward-sexp-safe'. + +2013-12-25 Lars Ingebrigtsen <larsi@gnus.org> + + * net/shr.el (shr-find-fill-point): Don't break lines before a + quotation mark. + (shr-char-kinsoku-bol-p): The quotation mark isn't a kinsoky BOL char. + (shr-find-fill-point): Remove the special checks for the quotation + mark, since `shr-char-kinsoku-bol-p' should now return the right + thing. + +2013-12-25 Kenjiro NAKAYAMA <nakayamakenjiro@gmail.com> + + * net/eww.el (eww-form-textarea): Use a different face for + textareas than text input since they have different keymaps + (bug#16142). + +2013-12-24 Fabián Ezequiel Gallina <fgallina@gnu.org> + + * progmodes/python.el (python-nav-beginning-of-statement): Speed + up (Bug#15295). + +2013-12-24 Lars Ingebrigtsen <larsi@gnus.org> + + * net/eww.el (eww-bookmark-browse): Use `quit-window' to restore + the window configuration. + +2013-12-24 Eli Zaretskii <eliz@gnu.org> + + * net/eww.el (eww-open-file): Ensure 3 slashes after "file:" when + we run on MS-Windows or MS-DOS. + +2013-12-24 Martin Rudalics <rudalics@gmx.at> + + * window.el (balance-windows-area): Call window-size instead of + window-height and window-width. Bug#16241. + 2013-12-24 Lars Ingebrigtsen <larsi@gnus.org> * net/eww.el (eww-bookmark-quit): Remove. diff --git a/lisp/net/eww.el b/lisp/net/eww.el index b7f50c19321..25309d16951 100644 --- a/lisp/net/eww.el +++ b/lisp/net/eww.el @@ -115,6 +115,14 @@ See also `eww-form-checkbox-selected-symbol'." :version "24.4" :group 'eww) +(defface eww-form-textarea + '((t (:background "#C0C0C0" + :foreground "black" + :box (:line-width 1)))) + "Face for eww textarea inputs." + :version "24.4" + :group 'eww) + (defvar eww-current-url nil) (defvar eww-current-dom nil) (defvar eww-current-source nil) @@ -167,7 +175,10 @@ word(s) will be searched for via `eww-search-prefix'." (defun eww-open-file (file) "Render a file using EWW." (interactive "fFile: ") - (eww (concat "file://" (expand-file-name file)))) + (eww (concat "file://" + (and (memq system-type '(windows-nt ms-dos)) + "/") + (expand-file-name file)))) (defun eww-render (status url &optional point) (let ((redirect (plist-get status :redirect))) @@ -773,7 +784,7 @@ See URL `https://developer.mozilla.org/en-US/docs/Web/HTML/Element/Input'.") (when (> pad 0) (insert (make-string pad ? )))) (add-face-text-property (line-beginning-position) - (point) 'eww-form-text) + (point) 'eww-form-textarea) (put-text-property (line-beginning-position) (point) 'local-map eww-textarea-map) (forward-line 1)) @@ -1083,8 +1094,6 @@ Differences in #targets are ignored." ;;; Bookmarks code (defvar eww-bookmarks nil) -(defvar eww-previous-window-configuration nil) -(make-variable-buffer-local 'eww-previous-window-configuration) (defun eww-add-bookmark () "Add the current page to the bookmarks." @@ -1129,7 +1138,6 @@ Differences in #targets are ignored." (unless eww-bookmarks (user-error "No bookmarks are defined")) (set-buffer (get-buffer-create "*eww bookmarks*")) - (setq eww-previous-window-configuration (current-window-configuration)) (eww-bookmark-mode) (let ((format "%-40s %s") (inhibit-read-only t) @@ -1188,8 +1196,6 @@ Differences in #targets are ignored." (unless bookmark (user-error "No bookmark on the current line")) (quit-window) - (when eww-previous-window-configuration - (set-window-configuration eww-previous-window-configuration)) (eww-browse-url (plist-get bookmark :url)))) (defun eww-next-bookmark () diff --git a/lisp/net/shr.el b/lisp/net/shr.el index 5c30bd8ac67..5b8ab28c837 100644 --- a/lisp/net/shr.el +++ b/lisp/net/shr.el @@ -179,13 +179,6 @@ cid: URL as the argument.") (goto-char begin) (shr-insert-document dom)))) -(defun shr-visit-file (file) - "Parse FILE as an HTML document, and render it in a new buffer." - (interactive "fHTML file name: ") - (with-temp-buffer - (insert-file-contents file) - (shr-render-buffer (current-buffer)))) - ;;;###autoload (defun shr-insert-document (dom) "Render the parsed document DOM into the current buffer. @@ -414,7 +407,9 @@ size, and full-buffer size." ;; of a line or the end of a line. (defmacro shr-char-kinsoku-bol-p (char) "Return non-nil if a line ought not to begin with CHAR." - `(aref (char-category-set ,char) ?>)) + `(let ((char ,char)) + (and (not (eq char ?')) + (aref (char-category-set char) ?>)))) (defmacro shr-char-kinsoku-eol-p (char) "Return non-nil if a line ought not to end with CHAR." `(aref (char-category-set ,char) ?<)) @@ -489,30 +484,19 @@ size, and full-buffer size." (eq (following-char) ? ) (shr-char-breakable-p (preceding-char)) (shr-char-breakable-p (following-char)) - (if (eq (preceding-char) ?') - (not (memq (char-after (- (point) 2)) - (list nil ?\n ? ))) - (and (shr-char-kinsoku-bol-p (preceding-char)) - (shr-char-breakable-p (following-char)) - (not (shr-char-kinsoku-bol-p (following-char))))) + (and (shr-char-kinsoku-bol-p (preceding-char)) + (shr-char-breakable-p (following-char)) + (not (shr-char-kinsoku-bol-p (following-char)))) (shr-char-kinsoku-eol-p (following-char)))) (backward-char 1)) - (if (and (not (or failed (eolp))) - (eq (preceding-char) ?')) - (while (not (or (setq failed (eolp)) - (eq (following-char) ? ) - (shr-char-breakable-p (following-char)) - (shr-char-kinsoku-eol-p (following-char)))) - (forward-char 1))) (if failed ;; There's no breakable point, so we give it up. (let (found) (goto-char bp) (unless shr-kinsoku-shorten - (while (and (setq found (re-search-forward - "\\(\\c>\\)\\| \\|\\c<\\|\\c|" - (line-end-position) 'move)) - (eq (preceding-char) ?'))) + (while (setq found (re-search-forward + "\\(\\c>\\)\\| \\|\\c<\\|\\c|" + (line-end-position) 'move))) (if (and found (not (match-beginning 1))) (goto-char (match-beginning 0))))) (or diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index aeee179c7e7..0646eade780 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el @@ -1279,15 +1279,21 @@ nested definitions." (defun python-nav-beginning-of-statement () "Move to start of current statement." (interactive "^") - (while (and (or (back-to-indentation) t) - (not (bobp)) - (when (or - (save-excursion - (forward-line -1) - (python-info-line-ends-backslash-p)) - (python-syntax-context 'string) - (python-syntax-context 'paren)) - (forward-line -1)))) + (back-to-indentation) + (let* ((ppss (syntax-ppss)) + (context-point + (or + (python-syntax-context 'paren ppss) + (python-syntax-context 'string ppss)))) + (cond ((bobp)) + (context-point + (goto-char context-point) + (python-nav-beginning-of-statement)) + ((save-excursion + (forward-line -1) + (python-info-line-ends-backslash-p)) + (forward-line -1) + (python-nav-beginning-of-statement)))) (point-marker)) (defun python-nav-end-of-statement (&optional noend) @@ -1418,25 +1424,36 @@ backward to previous block." (and (goto-char starting-pos) nil) (and (not (= (point) starting-pos)) (point-marker))))) -(defun python-nav-lisp-forward-sexp-safe (&optional arg) - "Safe version of standard `forward-sexp'. -When ARG > 0 move forward, else if ARG is < 0." - (or arg (setq arg 1)) +(defun python-nav--lisp-forward-sexp (&optional arg) + "Standard version `forward-sexp'. +It ignores completely the value of `forward-sexp-function' by +setting it to nil before calling `forward-sexp'. With positive +ARG move forward only one sexp, else move backwards." (let ((forward-sexp-function) - (paren-regexp - (if (> arg 0) (python-rx close-paren) (python-rx open-paren))) - (search-fn - (if (> arg 0) #'re-search-forward #'re-search-backward))) + (arg (if (or (not arg) (> arg 0)) 1 -1))) + (forward-sexp arg))) + +(defun python-nav--lisp-forward-sexp-safe (&optional arg) + "Safe version of standard `forward-sexp'. +When at end of sexp (i.e. looking at a opening/closing paren) +skips it instead of throwing an error. With positive ARG move +forward only one sexp, else move backwards." + (let* ((arg (if (or (not arg) (> arg 0)) 1 -1)) + (paren-regexp + (if (> arg 0) (python-rx close-paren) (python-rx open-paren))) + (search-fn + (if (> arg 0) #'re-search-forward #'re-search-backward))) (condition-case nil - (forward-sexp arg) + (python-nav--lisp-forward-sexp arg) (error (while (and (funcall search-fn paren-regexp nil t) (python-syntax-context 'paren))))))) -(defun python-nav--forward-sexp (&optional dir) +(defun python-nav--forward-sexp (&optional dir safe) "Move to forward sexp. -With positive Optional argument DIR direction move forward, else -backwards." +With positive optional argument DIR direction move forward, else +backwards. When optional argument SAFE is non-nil do not throw +errors when at end of sexp, skip it instead." (setq dir (or dir 1)) (unless (= dir 0) (let* ((forward-p (if (> dir 0) @@ -1454,7 +1471,9 @@ backwards." (eq (syntax-class (syntax-after (1- (point)))) (car (string-to-syntax ")"))))) ;; Inside a paren or looking at it, lisp knows what to do. - (python-nav-lisp-forward-sexp-safe dir)) + (if safe + (python-nav--lisp-forward-sexp-safe dir) + (python-nav--lisp-forward-sexp dir))) (t ;; This part handles the lispy feel of ;; `python-nav-forward-sexp'. Knowing everything about the @@ -1468,7 +1487,9 @@ backwards." ((python-info-end-of-statement-p) 'statement-end))) (next-sexp-pos (save-excursion - (python-nav-lisp-forward-sexp-safe dir) + (if safe + (python-nav--lisp-forward-sexp-safe dir) + (python-nav--lisp-forward-sexp dir)) (point))) (next-sexp-context (save-excursion @@ -1522,23 +1543,48 @@ backwards." (python-nav-beginning-of-statement)) (t (goto-char next-sexp-pos)))))))))) -(defun python-nav--backward-sexp () - "Move to backward sexp." - (python-nav--forward-sexp -1)) - (defun python-nav-forward-sexp (&optional arg) - "Move forward across one block of code. -With ARG, do it that many times. Negative arg -N means -move backward N times." + "Move forward across expressions. +With ARG, do it that many times. Negative arg -N means move +backward N times." (interactive "^p") (or arg (setq arg 1)) (while (> arg 0) - (python-nav--forward-sexp) + (python-nav--forward-sexp 1) (setq arg (1- arg))) (while (< arg 0) - (python-nav--backward-sexp) + (python-nav--forward-sexp -1) (setq arg (1+ arg)))) +(defun python-nav-backward-sexp (&optional arg) + "Move backward across expressions. +With ARG, do it that many times. Negative arg -N means move +backward N times." + (interactive "^p") + (or arg (setq arg 1)) + (python-nav-forward-sexp (- arg))) + +(defun python-nav-forward-sexp-safe (&optional arg) + "Move forward safely across expressions. +With ARG, do it that many times. Negative arg -N means move +backward N times." + (interactive "^p") + (or arg (setq arg 1)) + (while (> arg 0) + (python-nav--forward-sexp 1 t) + (setq arg (1- arg))) + (while (< arg 0) + (python-nav--forward-sexp -1 t) + (setq arg (1+ arg)))) + +(defun python-nav-backward-sexp-safe (&optional arg) + "Move backward safely across expressions. +With ARG, do it that many times. Negative arg -N means move +backward N times." + (interactive "^p") + (or arg (setq arg 1)) + (python-nav-forward-sexp-safe (- arg))) + (defun python-nav--up-list (&optional dir) "Internal implementation of `python-nav-up-list'. DIR is always 1 or -1 and comes sanitized from @@ -2206,7 +2252,7 @@ the python shell: (save-excursion (when (python-nav-if-name-main) (cons (point) - (progn (python-nav-forward-sexp) + (progn (python-nav-forward-sexp-safe) (point))))))) ;; Oh destructuring bind, how I miss you. (if-name-main-start (car if-name-main-start-end)) diff --git a/lisp/window.el b/lisp/window.el index 3b841747205..b58f8b85815 100644 --- a/lisp/window.el +++ b/lisp/window.el @@ -4681,12 +4681,12 @@ specific buffers." ;; (assert (eq next (or (cadr (member win wins)) (car wins)))) (let* ((horiz (< (car (window-pixel-edges win)) (car (window-pixel-edges next)))) - (areadiff (/ (- (* (window-height next pixelwise) - (window-width next pixelwise) + (areadiff (/ (- (* (window-size next nil pixelwise) + (window-size next t pixelwise) (buffer-local-value 'window-area-factor (window-buffer next))) - (* (window-height win pixelwise) - (window-width win pixelwise) + (* (window-size win nil pixelwise) + (window-size win t pixelwise) (buffer-local-value 'window-area-factor (window-buffer win)))) (max (buffer-local-value 'window-area-factor @@ -4694,10 +4694,10 @@ specific buffers." (buffer-local-value 'window-area-factor (window-buffer next))))) (edgesize (if horiz - (+ (window-height win pixelwise) - (window-height next pixelwise)) - (+ (window-width win pixelwise) - (window-width next pixelwise)))) + (+ (window-size win nil pixelwise) + (window-size next nil pixelwise)) + (+ (window-size win t pixelwise) + (window-size next t pixelwise)))) (diff (/ areadiff edgesize))) (when (zerop diff) ;; Maybe diff is actually closer to 1 than to 0. |