unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* [PATCH 1/5] eww: Use `user-error'.
       [not found] <cover.1387496431.git.ruediger@c-plusplus.de>
@ 2013-12-19 23:44 ` Rüdiger Sonderfeld
  2013-12-19 23:44 ` [PATCH 2/5] eww: Add menu for `eww-bookmark-mode' Rüdiger Sonderfeld
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 5+ messages in thread
From: Rüdiger Sonderfeld @ 2013-12-19 23:44 UTC (permalink / raw)
  To: emacs-devel; +Cc: Lars Magne Ingebrigtsen, Ted Zlatanov

* lisp/net/eww.el (eww-back-url, eww-forward-url, eww-next-url)
(eww-previous-url, eww-up-url, eww-top-url, eww-add-bookmark)
(eww-bookmark-prepare, eww-bookmark-kill, eww-bookmark-yank)
(eww-bookmark-browse, eww-next-bookmark, eww-previous-bookmark):
Use `user-error'.
---
 lisp/ChangeLog  |  8 ++++++++
 lisp/net/eww.el | 28 ++++++++++++++--------------
 2 files changed, 22 insertions(+), 14 deletions(-)

diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 85e961e..db57dbc 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,11 @@
+2013-12-19  Rüdiger Sonderfeld  <ruediger@c-plusplus.de>
+
+	* net/eww.el (eww-back-url, eww-forward-url, eww-next-url)
+	(eww-previous-url, eww-up-url, eww-top-url, eww-add-bookmark)
+	(eww-bookmark-prepare, eww-bookmark-kill, eww-bookmark-yank)
+	(eww-bookmark-browse, eww-next-bookmark, eww-previous-bookmark):
+	Use `user-error'.
+
 2013-12-19  Teodor Zlatanov  <tzz@lifelogs.com>
 
 	* net/eww.el (eww-exit, eww-close, eww-mode-map): Revert change of
diff --git a/lisp/net/eww.el b/lisp/net/eww.el
index 2263f81..feec873 100644
--- a/lisp/net/eww.el
+++ b/lisp/net/eww.el
@@ -474,7 +474,7 @@ (defun eww-back-url ()
   "Go to the previously displayed page."
   (interactive)
   (when (>= eww-history-position (length eww-history))
-    (error "No previous page"))
+    (user-error "No previous page"))
   (eww-save-history)
   (setq eww-history-position (+ eww-history-position 2))
   (eww-restore-history (elt eww-history (1- eww-history-position))))
@@ -483,7 +483,7 @@ (defun eww-forward-url ()
   "Go to the next displayed page."
   (interactive)
   (when (zerop eww-history-position)
-    (error "No next page"))
+    (user-error "No next page"))
   (eww-save-history)
   (eww-restore-history (elt eww-history (1- eww-history-position))))
 
@@ -505,7 +505,7 @@ (defun eww-next-url ()
   (interactive)
   (if eww-next-url
       (eww-browse-url (shr-expand-url eww-next-url eww-current-url))
-    (error "No `next' on this page")))
+    (user-error "No `next' on this page")))
 
 (defun eww-previous-url ()
   "Go to the page marked `previous'.
@@ -514,7 +514,7 @@ (defun eww-previous-url ()
   (interactive)
   (if eww-previous-url
       (eww-browse-url (shr-expand-url eww-previous-url eww-current-url))
-    (error "No `previous' on this page")))
+    (user-error "No `previous' on this page")))
 
 (defun eww-up-url ()
   "Go to the page marked `up'.
@@ -523,7 +523,7 @@ (defun eww-up-url ()
   (interactive)
   (if eww-up-url
       (eww-browse-url (shr-expand-url eww-up-url eww-current-url))
-    (error "No `up' on this page")))
+    (user-error "No `up' on this page")))
 
 (defun eww-top-url ()
   "Go to the page marked `top'.
@@ -535,7 +535,7 @@ (defun eww-top-url ()
 		      eww-home-url)))
     (if best-url
 	(eww-browse-url (shr-expand-url best-url eww-current-url))
-      (error "No `top' for this page"))))
+      (user-error "No `top' for this page"))))
 
 (defun eww-reload ()
   "Reload the current page."
@@ -1073,7 +1073,7 @@ (defun eww-add-bookmark ()
   (dolist (bookmark eww-bookmarks)
     (when (equal eww-current-url
 		 (plist-get bookmark :url))
-      (error "Already bookmarked")))
+      (user-error "Already bookmarked")))
   (if (y-or-n-p "bookmark this page? ")
       (progn
 	(let ((title (replace-regexp-in-string "[\n\t\r]" " " eww-current-title)))
@@ -1106,8 +1106,8 @@ (defun eww-list-bookmarks ()
 
 (defun eww-bookmark-prepare ()
   (eww-read-bookmarks)
-  (when (null eww-bookmarks)
-    (error "No bookmarks are defined"))
+  (unless eww-bookmarks
+    (user-error "No bookmarks are defined"))
   (set-buffer (get-buffer-create "*eww bookmarks*"))
   (eww-bookmark-mode)
   (let ((format "%-40s %s")
@@ -1135,7 +1135,7 @@ (defun eww-bookmark-kill ()
 	 (bookmark (get-text-property start 'eww-bookmark))
 	 (inhibit-read-only t))
     (unless bookmark
-      (error "No bookmark on the current line"))
+      (user-error "No bookmark on the current line"))
     (forward-line 1)
     (push (buffer-substring start (point)) eww-bookmark-kill-ring)
     (delete-region start (point))
@@ -1146,7 +1146,7 @@ (defun eww-bookmark-yank ()
   "Yank a previously killed bookmark to the current line."
   (interactive)
   (unless eww-bookmark-kill-ring
-    (error "No previously killed bookmark"))
+    (user-error "No previously killed bookmark"))
   (beginning-of-line)
   (let ((inhibit-read-only t)
 	(start (point))
@@ -1170,7 +1170,7 @@ (defun eww-bookmark-browse ()
   (interactive)
   (let ((bookmark (get-text-property (line-beginning-position) 'eww-bookmark)))
     (unless bookmark
-      (error "No bookmark on the current line"))
+      (user-error "No bookmark on the current line"))
     ;; We wish to leave this window, but if it's the only window here,
     ;; just let it remain.
     (ignore-errors
@@ -1192,7 +1192,7 @@ (defun eww-next-bookmark ()
       (setq bookmark (get-text-property (line-beginning-position)
 					'eww-bookmark))
       (unless bookmark
-	(error "No next bookmark")))
+	(user-error "No next bookmark")))
     (eww-browse-url (plist-get bookmark :url))))
 
 (defun eww-previous-bookmark ()
@@ -1211,7 +1211,7 @@ (defun eww-previous-bookmark ()
       (when (eolp)
 	(forward-line -1))
       (if (bobp)
-	  (error "No previous bookmark")
+	  (user-error "No previous bookmark")
 	(forward-line -1))
       (setq bookmark (get-text-property (line-beginning-position)
 					'eww-bookmark)))
-- 
1.8.5





^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/5] eww: Add menu for `eww-bookmark-mode'.
       [not found] <cover.1387496431.git.ruediger@c-plusplus.de>
  2013-12-19 23:44 ` [PATCH 1/5] eww: Use `user-error' Rüdiger Sonderfeld
@ 2013-12-19 23:44 ` Rüdiger Sonderfeld
  2013-12-19 23:44 ` [PATCH 3/5] eww: Use `setq-local' Rüdiger Sonderfeld
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 5+ messages in thread
From: Rüdiger Sonderfeld @ 2013-12-19 23:44 UTC (permalink / raw)
  To: emacs-devel; +Cc: Lars Magne Ingebrigtsen, Ted Zlatanov

* lisp/net/eww.el (eww-bookmark-mode-map): Add menu.
---
 lisp/ChangeLog  |  1 +
 lisp/net/eww.el | 11 +++++++++++
 2 files changed, 12 insertions(+)

diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index db57dbc..cf8553d 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -5,6 +5,7 @@
 	(eww-bookmark-prepare, eww-bookmark-kill, eww-bookmark-yank)
 	(eww-bookmark-browse, eww-next-bookmark, eww-previous-bookmark):
 	Use `user-error'.
+	(eww-bookmark-mode-map): Add menu.
 
 2013-12-19  Teodor Zlatanov  <tzz@lifelogs.com>
 
diff --git a/lisp/net/eww.el b/lisp/net/eww.el
index feec873..1da2bb2 100644
--- a/lisp/net/eww.el
+++ b/lisp/net/eww.el
@@ -1224,6 +1224,17 @@ (defvar eww-bookmark-mode-map
     (define-key map [(control k)] 'eww-bookmark-kill)
     (define-key map [(control y)] 'eww-bookmark-yank)
     (define-key map "\r" 'eww-bookmark-browse)
+
+    (easy-menu-define nil map
+      "Menu for `eww-bookmark-mode-map'."
+      '("Eww Bookmark"
+        ["Exit" eww-bookmark-quit t]
+        ["Browse" eww-bookmark-browse
+         :active (get-text-property (line-beginning-position) 'eww-bookmark)]
+        ["Kill" eww-bookmark-kill
+         :active (get-text-property (line-beginning-position) 'eww-bookmark)]
+        ["Yank" eww-bookmark-yank
+         :active eww-bookmark-kill-ring]))
     map))
 
 (define-derived-mode eww-bookmark-mode nil "eww bookmarks"
-- 
1.8.5





^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 3/5] eww: Use `setq-local'.
       [not found] <cover.1387496431.git.ruediger@c-plusplus.de>
  2013-12-19 23:44 ` [PATCH 1/5] eww: Use `user-error' Rüdiger Sonderfeld
  2013-12-19 23:44 ` [PATCH 2/5] eww: Add menu for `eww-bookmark-mode' Rüdiger Sonderfeld
@ 2013-12-19 23:44 ` Rüdiger Sonderfeld
  2013-12-19 23:44 ` [PATCH 4/5] eww: Add tool bar support Rüdiger Sonderfeld
  2013-12-19 23:44 ` [PATCH 5/5] eww: Check for `html-mode' using `fboundp' Rüdiger Sonderfeld
  4 siblings, 0 replies; 5+ messages in thread
From: Rüdiger Sonderfeld @ 2013-12-19 23:44 UTC (permalink / raw)
  To: emacs-devel; +Cc: Lars Magne Ingebrigtsen, Ted Zlatanov

* lisp/net/eww.el (eww-render, eww-mode): Use `setq-local'.
---
 lisp/ChangeLog  |  1 +
 lisp/net/eww.el | 26 +++++++++++++-------------
 2 files changed, 14 insertions(+), 13 deletions(-)

diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index cf8553d..54f6c77 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -6,6 +6,7 @@
 	(eww-bookmark-browse, eww-next-bookmark, eww-previous-bookmark):
 	Use `user-error'.
 	(eww-bookmark-mode-map): Add menu.
+	(eww-render, eww-mode): Use `setq-local'.
 
 2013-12-19  Teodor Zlatanov  <tzz@lifelogs.com>
 
diff --git a/lisp/net/eww.el b/lisp/net/eww.el
index 1da2bb2..a58b7ed 100644
--- a/lisp/net/eww.el
+++ b/lisp/net/eww.el
@@ -171,12 +171,12 @@ (defun eww-render (status url &optional point)
   (let ((redirect (plist-get status :redirect)))
     (when redirect
       (setq url redirect)))
-  (set (make-local-variable 'eww-next-url) nil)
-  (set (make-local-variable 'eww-previous-url) nil)
-  (set (make-local-variable 'eww-up-url) nil)
-  (set (make-local-variable 'eww-home-url) nil)
-  (set (make-local-variable 'eww-start-url) nil)
-  (set (make-local-variable 'eww-contents-url) nil)
+  (setq-local eww-next-url nil)
+  (setq-local eww-previous-url nil)
+  (setq-local eww-up-url nil)
+  (setq-local eww-home-url nil)
+  (setq-local eww-start-url nil)
+  (setq-local eww-contents-url nil)
   (let* ((headers (eww-parse-headers))
 	 (content-type
 	  (mail-header-parse-content-type
@@ -443,13 +443,13 @@ (define-derived-mode eww-mode nil "eww"
 
 \\{eww-mode-map}"
   ;; FIXME?  This seems a strange default.
-  (set (make-local-variable 'eww-current-url) 'author)
-  (set (make-local-variable 'eww-current-dom) nil)
-  (set (make-local-variable 'eww-current-source) nil)
-  (set (make-local-variable 'browse-url-browser-function) 'eww-browse-url)
-  (set (make-local-variable 'after-change-functions) 'eww-process-text-input)
-  (set (make-local-variable 'eww-history) nil)
-  (set (make-local-variable 'eww-history-position) 0)
+  (setq-local eww-current-url 'author)
+  (setq-local eww-current-dom nil)
+  (setq-local eww-current-source nil)
+  (setq-local browse-url-browser-function 'eww-browse-url)
+  (setq-local after-change-functions 'eww-process-text-input)
+  (setq-local eww-history nil)
+  (setq-local eww-history-position 0)
   (buffer-disable-undo)
   ;;(setq buffer-read-only t)
   )
-- 
1.8.5





^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 4/5] eww: Add tool bar support.
       [not found] <cover.1387496431.git.ruediger@c-plusplus.de>
                   ` (2 preceding siblings ...)
  2013-12-19 23:44 ` [PATCH 3/5] eww: Use `setq-local' Rüdiger Sonderfeld
@ 2013-12-19 23:44 ` Rüdiger Sonderfeld
  2013-12-19 23:44 ` [PATCH 5/5] eww: Check for `html-mode' using `fboundp' Rüdiger Sonderfeld
  4 siblings, 0 replies; 5+ messages in thread
From: Rüdiger Sonderfeld @ 2013-12-19 23:44 UTC (permalink / raw)
  To: emacs-devel; +Cc: Lars Magne Ingebrigtsen, Ted Zlatanov

* lisp/net/eww.el (eww-tool-bar-map): New variable.
  (eww-mode): Set `tool-bar-map'.
---
 lisp/ChangeLog  |  2 ++
 lisp/net/eww.el | 17 +++++++++++++++++
 2 files changed, 19 insertions(+)

diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 54f6c77..14d539d 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -7,6 +7,8 @@
 	Use `user-error'.
 	(eww-bookmark-mode-map): Add menu.
 	(eww-render, eww-mode): Use `setq-local'.
+	(eww-tool-bar-map): New variable.
+	(eww-mode): Set `tool-bar-map'.
 
 2013-12-19  Teodor Zlatanov  <tzz@lifelogs.com>
 
diff --git a/lisp/net/eww.el b/lisp/net/eww.el
index a58b7ed..cae5cfd 100644
--- a/lisp/net/eww.el
+++ b/lisp/net/eww.el
@@ -438,6 +438,21 @@ (defvar eww-mode-map
 	["List cookies" url-cookie-list t]))
     map))
 
+(defvar eww-tool-bar-map
+  (let ((map (make-sparse-keymap)))
+    (dolist (tool-bar-item
+             '((eww-quit . "close")
+               (eww-reload . "refresh")
+               (eww-back-url . "left-arrow")
+               (eww-forward-url . "right-arrow")
+               (eww-view-source . "show")
+               (eww-copy-page-url . "copy")
+               (eww-add-bookmark . "bookmark_add"))) ;; ...
+      (tool-bar-local-item-from-menu
+       (car tool-bar-item) (cdr tool-bar-item) map eww-mode-map))
+    map)
+  "Tool bar for `eww-mode'.")
+
 (define-derived-mode eww-mode nil "eww"
   "Mode for browsing the web.
 
@@ -450,6 +465,8 @@ (define-derived-mode eww-mode nil "eww"
   (setq-local after-change-functions 'eww-process-text-input)
   (setq-local eww-history nil)
   (setq-local eww-history-position 0)
+  (when (boundp 'tool-bar-map)
+   (setq-local tool-bar-map eww-tool-bar-map))
   (buffer-disable-undo)
   ;;(setq buffer-read-only t)
   )
-- 
1.8.5





^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 5/5] eww: Check for `html-mode' using `fboundp'.
       [not found] <cover.1387496431.git.ruediger@c-plusplus.de>
                   ` (3 preceding siblings ...)
  2013-12-19 23:44 ` [PATCH 4/5] eww: Add tool bar support Rüdiger Sonderfeld
@ 2013-12-19 23:44 ` Rüdiger Sonderfeld
  4 siblings, 0 replies; 5+ messages in thread
From: Rüdiger Sonderfeld @ 2013-12-19 23:44 UTC (permalink / raw)
  To: emacs-devel; +Cc: Lars Magne Ingebrigtsen, Ted Zlatanov

`html-mode' is provided by `sgml-mode' in GNU Emacs.  Therefore it
should be checked for with `fboundp' instead of `featurep'.

* lisp/net/eww.el (eww-view-source): Check for `html-mode' with
  `fboundp'.
---
 lisp/ChangeLog  | 1 +
 lisp/net/eww.el | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 14d539d..c57620c 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -9,6 +9,7 @@
 	(eww-render, eww-mode): Use `setq-local'.
 	(eww-tool-bar-map): New variable.
 	(eww-mode): Set `tool-bar-map'.
+	(eww-view-source): Check for `html-mode' with `fboundp'.
 
 2013-12-19  Teodor Zlatanov  <tzz@lifelogs.com>
 
diff --git a/lisp/net/eww.el b/lisp/net/eww.el
index cae5cfd..df53d80 100644
--- a/lisp/net/eww.el
+++ b/lisp/net/eww.el
@@ -388,7 +388,7 @@ (defun eww-view-source ()
       (delete-region (point-min) (point-max))
       (insert (or eww-current-source "no source"))
       (goto-char (point-min))
-      (when (featurep 'html-mode)
+      (when (fboundp 'html-mode)
         (html-mode)))
     (view-buffer buf)))
 
-- 
1.8.5




^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2013-12-19 23:44 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <cover.1387496431.git.ruediger@c-plusplus.de>
2013-12-19 23:44 ` [PATCH 1/5] eww: Use `user-error' Rüdiger Sonderfeld
2013-12-19 23:44 ` [PATCH 2/5] eww: Add menu for `eww-bookmark-mode' Rüdiger Sonderfeld
2013-12-19 23:44 ` [PATCH 3/5] eww: Use `setq-local' Rüdiger Sonderfeld
2013-12-19 23:44 ` [PATCH 4/5] eww: Add tool bar support Rüdiger Sonderfeld
2013-12-19 23:44 ` [PATCH 5/5] eww: Check for `html-mode' using `fboundp' Rüdiger Sonderfeld

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).