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

[ENHANCEMENT] More uniform and useful progress / abort messages [PATCH]



The attached patch makes progress messages more uniform and more useful,
IMO.

1. Separate the URL from "..." for easier selecting.

2. Add helpful hints in the buffer of user options while a process is
   busy. This is desirable because messages are transitory - the user
   can easily miss them when dealing with many windows or frames.

3. When the user aborts a process, indicate clearly that's what
   happened.

4. Combined two snippets that dealt with this. They had slightly
   different algorithms, so I kept one set in comments, for the record.

What do you think?

-- 
hkp://keys.gnupg.net
CA45 09B5 5351 7C11 A9D1  7286 0036 9E45 1595 8BC0
Index: ChangeLog
===================================================================
RCS file: /storage/cvsroot/emacs-w3m/ChangeLog,v
retrieving revision 1.3668
diff -b -u -p -r1.3668 ChangeLog
--- ChangeLog	17 May 2018 04:21:01 -0000	1.3668
+++ ChangeLog	18 May 2018 15:05:56 -0000
@@ -1,3 +1,15 @@
+2018-05-18  Boruch Baum  <boruch_baum@xxxxxxx>
+
+	* w3m.el (w3m-display-progress-message): Combine code from
+	`w3m-retrieve-and-render', separate url from "...", and add user-friendly
+	advice message.
+	(w3m-retrieve-and-render): Replace snippet with call to
+	`w3m-display-progress-message'.
+
+	* w3m-proc.el (w3m-process-stop):  Document in the buffer when an
+	operation has been aborted by the user, what that operation was, and
+	remove progress message.
+
 2018-05-17  Katsumi Yamaoka  <yamaoka@xxxxxxx>

 	Work for mailto urls.
Index: w3m.el
===================================================================
RCS file: /storage/cvsroot/emacs-w3m/w3m.el,v
retrieving revision 1.1711
diff -b -u -p -r1.1711 w3m.el
--- w3m.el	17 May 2018 04:21:01 -0000	1.1711
+++ w3m.el	18 May 2018 15:05:57 -0000
@@ -6440,10 +6444,7 @@ called with t as an argument.  Otherwise
     (set-window-hscroll nil 0)
     (let ((inhibit-read-only t))
       (erase-buffer)
-      (insert-char ?\n (/ (window-height) 2))
-      (insert-char ?  (max 0 (/ (- (window-width) (length url) 11) 2)))
-      (insert "Reading " url "...")
-      (sit-for 0)))
+      (w3m-display-progress-message url)))
   (unless (and w3m-current-ssl
 	       w3m-confirm-leaving-secure-page
 	       ;; Permit leaving safe pages without confirmation for
@@ -7229,15 +7230,18 @@ compatibility which is described in Sect

 (defun w3m-display-progress-message (url)
   "Show \"Reading URL...\" message in the middle of a buffer."
-  (insert (make-string (max 0 (/ (1- (window-height)) 2)) ?\n)
-	  "Reading " (w3m-url-readable-string (w3m-url-strip-authinfo url))
-	  "...")
-  (beginning-of-line)
-  (let ((fill-column (window-width)))
-    (center-region (point) (point-max)))
-  (goto-char (point-min))
-  (put-text-property (point) (point-max) 'w3m-progress-message t)
-  (sit-for 0))
+  (let ((indent (make-string (max 0 (/ (- (window-width) (length url) 11) 2)) ? )))
+    (insert-char ?\n (max 0 (- (/ (window-height) 2) 3)))
+;   (insert-char ?\n (max 0 (/ (1- (window-height)) 2)))
+    (insert (substitute-command-keys (concat
+; indent "Reading " url " ...\n\n"
+  indent "Reading " (w3m-url-readable-string (w3m-url-strip-authinfo url)) " ...\n\n"
+  indent "`\\<w3m-mode-map>\\[w3m-process-stop]' to abort this operation, or\n"
+  indent "`\\<w3m-mode-map>\\[w3m-search-new-session]' to perform a search in a new buffer, or\n"
+  indent "`\\<w3m-mode-map>\\[w3m-goto-url-new-session]' to visit a URL in a new buffer, or\n"
+  indent "do any emacs work in any other buffer, or just wait ... ")))
+  (put-text-property (point-min) (point-max) 'w3m-progress-message t)
+  (sit-for 0)))

 (defun w3m-view-this-url-1 (url reload new-session)
   (lexical-let ((url url)
Index: w3m-proc.el
===================================================================
RCS file: /storage/cvsroot/emacs-w3m/w3m-proc.el,v
retrieving revision 1.88
diff -b -u -p -r1.88 w3m-proc.el
--- w3m-proc.el	4 Oct 2017 04:22:53 -0000	1.88
+++ w3m-proc.el	18 May 2018 15:05:57 -0000
@@ -173,7 +173,7 @@

 (defun w3m-process-push (handler command arguments)
   "Generate a new `w3m-process' object which is provided by HANDLER,
-ARGUMENTS and this buffer, regist it to `w3m-process-queue', and
+ARGUMENTS and this buffer, register it to `w3m-process-queue', and
 return it."
   (let ((x (assoc (cons command arguments) w3m-process-queue)))
     (unless x
@@ -298,11 +298,11 @@ which have no handler."
   (if w3m-process-queue
       (w3m-process-start-queued-processes)
     (when (and w3m-clear-display-while-reading
-	       (progn
 		 (goto-char (point-min))
-		 (looking-at "\n* *Reading [^\n]+\\.\\.\\.\\'")))
+               (re-search-forward "\n*\\( *\\)Reading [^\n]+\\(\\.\\.\\.\\)" nil t))
       (let ((inhibit-read-only t))
-	(erase-buffer)
+       (delete-region (match-beginning 2) (point-max))
+       (insert "\n\n"  (match-string 1) "Operation aborted by user.")
 	(setq w3m-current-url nil
 	      w3m-current-title nil))))
   (w3m-force-window-update-later buffer))