Commit a1cf6ec1 authored by UJ's avatar UJ
Browse files

newsticker: Context menu in treeview's tree.

* net/newst-treeview.el (newsticker--treeview-list-add-item)
(newsticker--treeview-propertize-tag): Bind tree menu to mouse-3.
(newsticker--treeview-create-groups-menu)
(newsticker--treeview-create-tree-menu): Removed.
(newsticker--treeview-tree-open-menu): New.
(newsticker-treeview-tree-click): Pass event to
`newsticker-treeview-tree-do-click'.
(newsticker-treeview-tree-do-click): Open treemenu on mouse-3.
parent 952c6c8f
2014-12-06 Ulf Jasper <ulf.jasper@web.de>
* net/newst-treeview.el (newsticker--treeview-list-add-item)
(newsticker--treeview-propertize-tag): Bind tree menu to mouse-3.
(newsticker--treeview-create-groups-menu)
(newsticker--treeview-create-tree-menu): Removed.
(newsticker--treeview-tree-open-menu): New.
(newsticker-treeview-tree-click): Pass event to
`newsticker-treeview-tree-do-click'.
(newsticker-treeview-tree-do-click): Open treemenu on mouse-3.
2014-12-05 Juri Linkov <juri@linkov.net> 2014-12-05 Juri Linkov <juri@linkov.net>
* comint.el (comint-history-isearch-search) * comint.el (comint-history-isearch-search)
......
...@@ -328,7 +328,8 @@ If string SHOW-FEED is non-nil it is shown in the item string." ...@@ -328,7 +328,8 @@ If string SHOW-FEED is non-nil it is shown in the item string."
(while (search-forward "\n" nil t) (while (search-forward "\n" nil t)
(replace-match " ")) (replace-match " "))
(let ((map (make-sparse-keymap))) (let ((map (make-sparse-keymap)))
(define-key map [mouse-1] 'newsticker-treeview-tree-click) (dolist (key'([mouse-1] [mouse-3]))
(define-key map key 'newsticker-treeview-tree-click))
(define-key map "\n" 'newsticker-treeview-show-item) (define-key map "\n" 'newsticker-treeview-show-item)
(define-key map "\C-m" 'newsticker-treeview-show-item) (define-key map "\C-m" 'newsticker-treeview-show-item)
(add-text-properties pos1 (point-max) (add-text-properties pos1 (point-max)
...@@ -945,7 +946,8 @@ arguments NT-ID, FEED, and VFEED are added as properties." ...@@ -945,7 +946,8 @@ arguments NT-ID, FEED, and VFEED are added as properties."
(map (make-sparse-keymap))) (map (make-sparse-keymap)))
(if (and num-new (> num-new 0)) (if (and num-new (> num-new 0))
(setq face 'newsticker-treeview-new-face)) (setq face 'newsticker-treeview-new-face))
(define-key map [mouse-1] 'newsticker-treeview-tree-click) (dolist (key '([mouse-1] [mouse-3]))
(define-key map key 'newsticker-treeview-tree-click))
(define-key map "\n" 'newsticker-treeview-tree-do-click) (define-key map "\n" 'newsticker-treeview-tree-do-click)
(define-key map "\C-m" 'newsticker-treeview-tree-do-click) (define-key map "\C-m" 'newsticker-treeview-tree-do-click)
(propertize tag 'face face 'keymap map (propertize tag 'face face 'keymap map
...@@ -1960,37 +1962,22 @@ Return t if groups have changed, nil otherwise." ...@@ -1960,37 +1962,22 @@ Return t if groups have changed, nil otherwise."
;; ====================================================================== ;; ======================================================================
;;; Modes ;;; Modes
;; ====================================================================== ;; ======================================================================
(defun newsticker--treeview-create-groups-menu (group-list (defun newsticker--treeview-tree-open-menu (event)
excluded-group) "Open tree menu at position of EVENT."
"Create menu for GROUP-LIST omitting EXCLUDED-GROUP." (let* ((feed-name newsticker--treeview-current-feed)
(let ((menu (make-sparse-keymap (if (stringp (car group-list)) (menu (make-sparse-keymap feed-name)))
(car group-list)
"Move to group..."))))
(mapc (lambda (g)
(when (listp g)
(let ((title (if (stringp (car g))
(car g)
"Move to group...")))
(unless (eq g excluded-group)
(define-key menu (vector (intern title))
(list 'menu-item title
(newsticker--treeview-create-groups-menu
(cdr g) excluded-group)))))))
(reverse group-list))
menu))
(defun newsticker--treeview-create-tree-menu (feed-name)
"Create tree menu for FEED-NAME."
(let ((menu (make-sparse-keymap feed-name)))
(define-key menu [newsticker-treeview-mark-list-items-old] (define-key menu [newsticker-treeview-mark-list-items-old]
(list 'menu-item "Mark all items old" (list 'menu-item "Mark all items old"
'newsticker-treeview-mark-list-items-old)) 'newsticker-treeview-mark-list-items-old))
(define-key menu [move] (define-key menu [newsticker-treeview-get-news]
(list 'menu-item "Move to group..." (list 'menu-item (concat "Get news for " feed-name)
(newsticker--treeview-create-groups-menu 'newsticker-treeview-get-news))
newsticker-groups (define-key menu [newsticker-get-all-news]
(newsticker--group-get-group feed-name)))) (list 'menu-item "Get news for all feeds"
menu)) 'newsticker-get-all-news))
(let ((choice (x-popup-menu event menu)))
(when choice
(funcall (car choice))))))
(defvar newsticker-treeview-list-menu (defvar newsticker-treeview-list-menu
(let ((menu (make-sparse-keymap "Newsticker List"))) (let ((menu (make-sparse-keymap "Newsticker List")))
...@@ -2099,7 +2086,7 @@ Return t if groups have changed, nil otherwise." ...@@ -2099,7 +2086,7 @@ Return t if groups have changed, nil otherwise."
(newsticker--treeview-restore-layout) (newsticker--treeview-restore-layout)
(save-excursion (save-excursion
(switch-to-buffer (window-buffer (posn-window (event-end event)))) (switch-to-buffer (window-buffer (posn-window (event-end event))))
(newsticker-treeview-tree-do-click (posn-point (event-end event))))) (newsticker-treeview-tree-do-click (posn-point (event-end event)) event)))
(defun newsticker-treeview-tree-do-click (&optional pos event) (defun newsticker-treeview-tree-do-click (&optional pos event)
"Actually handle click event. "Actually handle click event.
...@@ -2119,7 +2106,11 @@ POS gives the position where EVENT occurred." ...@@ -2119,7 +2106,11 @@ POS gives the position where EVENT occurred."
(setq w (newsticker--treeview-get-node-by-id nt-id)) (setq w (newsticker--treeview-get-node-by-id nt-id))
(widget-put w :nt-selected t) (widget-put w :nt-selected t)
(widget-apply w :action event) (widget-apply w :action event)
(newsticker--treeview-set-current-node w)))))) (newsticker--treeview-set-current-node w)
(and event
(eq 'mouse-3 (car event))
(sit-for 0)
(newsticker--treeview-tree-open-menu event)))))))
(newsticker--treeview-tree-update-highlight)) (newsticker--treeview-tree-update-highlight))
(defun newsticker--treeview-restore-layout () (defun newsticker--treeview-restore-layout ()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment