From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Katsumi Yamaoka Newsgroups: gmane.emacs.bugs Subject: bug#28907: 26.0.90; [eww] some problems in input/textarea Date: Fri, 20 Oct 2017 17:39:29 +0900 Organization: Emacsen advocacy group Message-ID: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: blaine.gmane.org 1508488880 22003 195.159.176.226 (20 Oct 2017 08:41:20 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 20 Oct 2017 08:41:20 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.90 (i686-pc-cygwin) To: 28907@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Oct 20 10:41:15 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e5Srd-0004MH-04 for geb-bug-gnu-emacs@m.gmane.org; Fri, 20 Oct 2017 10:41:09 +0200 Original-Received: from localhost ([::1]:52655 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e5Sri-000158-LC for geb-bug-gnu-emacs@m.gmane.org; Fri, 20 Oct 2017 04:41:14 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:47050) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e5Srb-000152-N0 for bug-gnu-emacs@gnu.org; Fri, 20 Oct 2017 04:41:09 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e5SrX-00086l-OB for bug-gnu-emacs@gnu.org; Fri, 20 Oct 2017 04:41:07 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:42393) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e5SrX-00086S-KA for bug-gnu-emacs@gnu.org; Fri, 20 Oct 2017 04:41:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1e5SrX-0002qE-CC for bug-gnu-emacs@gnu.org; Fri, 20 Oct 2017 04:41:03 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Katsumi Yamaoka Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 20 Oct 2017 08:41:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 28907 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.150848883910882 (code B ref -1); Fri, 20 Oct 2017 08:41:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 20 Oct 2017 08:40:39 +0000 Original-Received: from localhost ([127.0.0.1]:51074 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e5Sr9-0002pS-9f for submit@debbugs.gnu.org; Fri, 20 Oct 2017 04:40:39 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:55994) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e5Sr7-0002pA-2N for submit@debbugs.gnu.org; Fri, 20 Oct 2017 04:40:37 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e5Sr0-0007pQ-B1 for submit@debbugs.gnu.org; Fri, 20 Oct 2017 04:40:31 -0400 Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:39807) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e5Sr0-0007pB-6o for submit@debbugs.gnu.org; Fri, 20 Oct 2017 04:40:30 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:46964) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e5Sqy-00013A-Hi for bug-gnu-emacs@gnu.org; Fri, 20 Oct 2017 04:40:29 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e5Squ-0007in-If for bug-gnu-emacs@gnu.org; Fri, 20 Oct 2017 04:40:28 -0400 Original-Received: from mail-hampton.hostforweb.net ([205.234.186.191]:41656 helo=hampton.hostforweb.net) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e5Sqt-0007KB-CC for bug-gnu-emacs@gnu.org; Fri, 20 Oct 2017 04:40:23 -0400 Original-Received: from s70.gtokyofl21.vectant.ne.jp ([202.215.75.70]:60000 helo=localhost) by hampton.hostforweb.net with esmtpsa (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.89) (envelope-from ) id 1e5Sq5-000R8k-10; Fri, 20 Oct 2017 03:39:37 -0500 X-Face: #kKnN,xUnmKia.'[pp`; Omh}odZK)?7wQSl"4o04=EixTF+V[""w~iNbM9ZL+.b*_CxUmFk B#Fu[*?MZZH@IkN:!"\w%I_zt>[$nm7nQosZ<3eu; B:$Q_:p!',P.c0-_Cy[dz4oIpw0ESA^D*1Lw= L&i*6&( Cancel-Lock: sha1:Xd7BhJbyCn4u969qMqS+Zxyzr8s= X-OutGoing-Spam-Status: No, score=-2.9 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - hampton.hostforweb.net X-AntiAbuse: Original Domain - gnu.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - jpl.org X-Get-Message-Sender-Via: hampton.hostforweb.net: authenticated_id: yamaoka/from_h X-Authenticated-Sender: hampton.hostforweb.net: yamaoka@jpl.org X-Source: X-Source-Args: X-Source-Dir: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (barebone) [generic] [fuzzy] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:138750 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hi, There are some problems with an input form and a textarea as follows: =E3=83=BBCan't enter text at the beginnig of input/textarea if there is a link just above the form. =E3=83=BBCan't enter space at (1- eol). =E3=83=BBCan't kill a line. =E3=83=BBCan't undo. =E3=83=BBCan't retrieve the response for the submit in a certain site. =E3=83=BBPadding width gets incorrect if there is a wide character. =E3=83=BBA major mode command like `g' doesn't work at the right outside of textarea. I tested and tried to improve them in mainly: [1] A patch is below. Some of them would have to be improved further, though. Thanks. [1] This is an English-Japanese translation service; you can find the textarea slot for entering an original English text at the line 191 in an eww buffer. Please note that the translation is not so accurate. ;-) P.S. I will be absent from the net till Thursday, sorry. In GNU Emacs 26.0.90 (build 1, i686-pc-cygwin, GTK+ Version 3.18.9) of 2017-10-20 built on localhost Windowing system distributor 'The Cygwin/X Project', version 11.0.11900000 * lisp/net/eww.el (eww, eww-reload): Disable undo. (eww-render): Enable undo when a user enters things in input/textarea. (eww-tag-a): Make keymap prop non-sticky. (eww-kill-line): New command. (eww-textarea-map): Use it. (eww-process-text-input): Enable a user to enter space at (1- eol); don't break the form when killing a line at the beginning of the form. (eww-tag-textarea): Treat textarea's text as its value if it is null; work the padding correctly when there is a wide character; make keymap prop non-sticky. --=-=-= Content-Type: text/x-patch Content-Disposition: inline --- eww.el~ 2017-09-14 22:06:50.000000000 +0000 +++ eww.el 2017-10-20 08:36:56.427163000 +0000 @@ -256,6 +256,7 @@ (if (eq major-mode 'eww-mode) (current-buffer) (get-buffer-create "*eww*"))) + (buffer-disable-undo) (eww-setup-buffer) ;; Check whether the domain only uses "Highly Restricted" Unicode ;; IDNA characters. If not, transform to punycode to indicate that @@ -397,7 +398,10 @@ (setq eww-history-position 0) (and last-coding-system-used (set-buffer-file-coding-system last-coding-system-used)) - (run-hooks 'eww-after-render-hook))) + (run-hooks 'eww-after-render-hook) + (add-hook 'before-change-functions + (lambda (&rest _args) (buffer-enable-undo)) + nil t))) (kill-buffer data-buffer)))) (defun eww-parse-headers () @@ -546,7 +550,8 @@ (eww-handle-link dom) (let ((start (point))) (shr-tag-a dom) - (put-text-property start (point) 'keymap eww-link-keymap))) + (add-text-properties start (point) (list 'keymap eww-link-keymap + 'rear-nonsticky t)))) (defun eww-update-header-line-format () (setq header-line-format @@ -916,6 +921,7 @@ a prefix argument), don't reload the page from the network, but just re-display the HTML already fetched." (interactive "P") + (buffer-disable-undo) (let ((url (plist-get eww-data :url))) (if local (if (null (plist-get eww-data :dom)) @@ -966,6 +972,7 @@ (define-key map [(control c) (control c)] 'eww-submit) (define-key map [?\t] 'shr-next-link) (define-key map [?\M-\t] 'shr-previous-link) + (define-key map "\C-k" 'eww-kill-line) map)) (defvar eww-select-map @@ -990,6 +997,13 @@ (when (> (point) start) (forward-char 1)))) +;; FIXME: make it usable for `eww-text-map'. +(defun eww-kill-line (&optional _arg) + "Kill the rest of the current line." + (interactive "P") + (let ((inhibit-read-only t)) + (kill-region (point) (line-end-position)))) + (defun eww-beginning-of-field () (cond ((bobp) @@ -1134,6 +1148,8 @@ (1- (line-end-position)) (eww-end-of-field))) (while (and (> length 0) + ;; Don't delete space a user enters at (1- eol). + (< end (point)) (eql (char-after (1- (point))) ? )) (delete-region (1- (point)) (point)) (cl-decf length)))) @@ -1141,10 +1157,11 @@ ;; Add padding. (save-excursion (goto-char end) - (goto-char - (if (equal type "textarea") - (1- (line-end-position)) - (1+ (eww-end-of-field)))) + (if (equal type "textarea") + ;; Don't move point if the line is empty. + (unless (and (bolp) (eolp)) + (goto-char (1- (line-end-position)))) + (goto-char (1+ (eww-end-of-field)))) (let ((start (point))) (insert (make-string (abs length) ? )) (set-text-properties start (point) properties)) @@ -1166,13 +1183,14 @@ 'display (make-string (length value) ?*))))))))) (defun eww-tag-textarea (dom) - (let ((start (point)) - (value (or (dom-attr dom 'value) "")) + (let ((value (or (dom-attr dom 'value) (dom-text dom))) (lines (string-to-number (or (dom-attr dom 'rows) "10"))) (width (string-to-number (or (dom-attr dom 'cols) "10"))) - end) + start end) (shr-ensure-newline) - (insert value) + (setq start (point)) + (let ((fill-column width)) + (fill-region start (progn (insert value) (point)))) (shr-ensure-newline) (when (< (count-lines start (point)) lines) (dotimes (_ (- lines (count-lines start (point)))) @@ -1181,14 +1199,16 @@ (goto-char start) (while (< (point) end) (end-of-line) - (let ((pad (- width (- (point) (line-beginning-position))))) + (let ((pad (- width (current-column)))) ;; There may be a wide character. (when (> pad 0) (insert (make-string pad ? )))) (add-face-text-property (line-beginning-position) (point) 'eww-form-textarea) - (put-text-property (line-beginning-position) (point) 'inhibit-read-only t) - (put-text-property (line-beginning-position) (point) - 'local-map eww-textarea-map) + (add-text-properties (line-beginning-position) (point) + `(inhibit-read-only t + local-map ,eww-textarea-map + ;; Enable the major mode keymap on newlines. + rear-nonsticky t)) (forward-line 1)) (put-text-property start (point) 'eww-form (list :eww-form eww-form --=-=-=--