From: Ulf Jasper Date: Wed, 24 Feb 2021 18:26:37 +0000 (+0100) Subject: Add options to use feed names from newticker-url-list X-Git-Tag: emacs-28.0.90~3563 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=654cb8e6b7fbdca32f07609cafe906e2470cc73d;p=emacs.git Add options to use feed names from newticker-url-list * lisp/net/newst-treeview.el (newsticker-treeview-use-feed-name-from-url-list-in-treeview): New. (newsticker-treeview-use-feed-name-from-url-list-in-itemview): New. (newsticker--treeview-item-show): Show feed name from newsticker-url-list if wanted. (newsticker--treeview-propertize-tag): Add argument 'tooltip'. (newsticker--treeview-tree-get-tag): Usefeed name from newsticker-url-list if wanted. (Fixes third issue in Bug#41376.) --- diff --git a/lisp/net/newst-treeview.el b/lisp/net/newst-treeview.el index 618a791c575..c0b5e34f681 100644 --- a/lisp/net/newst-treeview.el +++ b/lisp/net/newst-treeview.el @@ -119,6 +119,18 @@ applies to newsticker only." :type 'boolean :group 'newsticker-treeview) +(defcustom newsticker-treeview-use-feed-name-from-url-list-in-treeview + t + "Use the feed names from 'newsticker-url-list' for display in treeview." + :type 'boolean + :group 'newsticker-treeview) + +(defcustom newsticker-treeview-use-feed-name-from-url-list-in-itemview + t + "Use feed names from 'newsticker-url-list' in itemview." + :type 'boolean + :group 'newsticker-treeview) + (defvar newsticker-groups '("Feeds") "List of feed groups, used in the treeview frontend. @@ -738,11 +750,14 @@ for the button." (img (newsticker--image-read feed-name-symbol nil 40))) (if (and (display-images-p) img) (newsticker--insert-image img (car item)) - (insert (newsticker--real-feed-name feed-name-symbol)))) + (insert (if newsticker-treeview-use-feed-name-from-url-list-in-itemview + (symbol-name feed-name-symbol) + (newsticker--real-feed-name feed-name-symbol))))) (add-text-properties (point-min) (point) (list 'face 'newsticker-feed-face 'mouse-face 'highlight - 'help-echo "Visit in web browser." + 'help-echo (concat (newsticker--real-feed-name feed-name-symbol) + "\nClick to visit in web browser.") :nt-link (newsticker--link item) 'keymap newsticker--treeview-url-keymap)) (setq pos (point)) @@ -933,10 +948,10 @@ Optional arguments CHANGED-WIDGET and EVENT are ignored." (newsticker-treeview-mode))) (defun newsticker--treeview-propertize-tag (tag &optional num-new nt-id feed - vfeed) + vfeed tooltip) "Return propertized copy of string TAG. Optional argument NUM-NEW is used for choosing face, other -arguments NT-ID, FEED, and VFEED are added as properties." +arguments NT-ID, FEED, VFEED and TOOLTIP are added as properties." ;;(message "newsticker--treeview-propertize-tag `%s' %s" feed nt-id) (let ((face 'newsticker-treeview-face) (map (make-sparse-keymap))) @@ -950,14 +965,14 @@ arguments NT-ID, FEED, and VFEED are added as properties." :nt-id nt-id :nt-feed feed :nt-vfeed vfeed - 'help-echo tag + 'help-echo tooltip 'mouse-face 'highlight))) (defun newsticker--treeview-tree-get-tag (feed-name vfeed-name &optional nt-id) "Return a tag string for either FEED-NAME or, if it is nil, for VFEED-NAME. Optional argument NT-ID is added to the tag's properties." - (let (tag (num-new 0)) + (let (tag tooltip (num-new 0)) (cond (vfeed-name (cond ((string= vfeed-name "new") (setq num-new (newsticker--stat-num-items-total 'new)) @@ -970,18 +985,29 @@ Optional argument NT-ID is added to the tag's properties." (setq tag (format "Obsolete items (%d)" num-new))) ((string= vfeed-name "all") (setq num-new (newsticker--stat-num-items-total)) - (setq tag (format "All items (%d)" num-new))))) + (setq tag (format "All items (%d)" num-new)))) + (setq tooltip tag)) (feed-name (setq num-new (newsticker--stat-num-items-for-group (intern feed-name) 'new 'immortal)) (setq tag (format "%s (%d)" - (newsticker--real-feed-name (intern feed-name)) - num-new)))) + (if newsticker-treeview-use-feed-name-from-url-list-in-itemview + feed-name + (newsticker--real-feed-name (intern feed-name))) + num-new)) + (setq tooltip + (if (newsticker--group-get-group feed-name) + tag + (format "%s (%d)\n%s" + feed-name + num-new + (newsticker--real-feed-name (intern feed-name))))))) (if tag (newsticker--treeview-propertize-tag tag num-new nt-id - feed-name vfeed-name)))) + feed-name vfeed-name + tooltip)))) (defun newsticker--stat-num-items-for-group (feed-name-symbol &rest ages) "Count number of items in feed FEED-NAME-SYMBOL that have an age matching AGES."