blob: 33c271b79d8405747d15cae0668f6e4a916838ac (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
;;; hui-dired-sidebar.el --- Hyperbole Smart Key support for dired sidebar -*- lexical-binding: t; -*-
;;
;; Author: Mats Lidell
;;
;; Orig-Date: 25-Jul-20
;; Last-Mod: 24-Jan-22 at 00:18:47 by Bob Weiner
;;
;; SPDX-License-Identifier: GPL-3.0-or-later
;;
;; Copyright (C) 2020-2021 Free Software Foundation, Inc. See the
;; "HY-COPY" file for license information.
;;
;; This file is part of GNU Hyperbole.
;;; Commentary:
;;; Code:
;;; ************************************************************************
;;; Other required Elisp libraries
;;; ************************************************************************
(eval-and-compile (require 'dired-sidebar nil t))
;;; ************************************************************************
;;; Public declarations
;;; ************************************************************************
(declare-function dired-sidebar-toggle-sidebar "ext:dired-sidebar")
(defvar dired-sidebar-cycle-subtree-on-click)
;;; ************************************************************************
;;; smart-dired-sidebar functions
;;; ************************************************************************
;;;###autoload
(defun smart-dired-sidebar ()
"Use a single key or mouse key to manipulate directory entries.
Invoked via a key press when in dired-sidebar-mode. It assumes
that its caller has already checked that the key was pressed in
an appropriate buffer and has moved the cursor there.
If key is pressed:
(1) within an entry line, the item is displayed for editing,
normally in another window, or if it is a directory and
`dired-sidebar-cycle-subtree-on-click' is t it will expand
and collapse the entry
(2) at the end of an entry line: invoke `action-key-eol-function',
typically to scroll up proportionally, if an Action Key press; invoke
`assist-key-eol-function', typically to scroll down proportionally,
if an Asisst Key press;
(3) on the first line of the buffer (other than the end of line),
dired is run on the current directory of this dired-sidebar;
(4) at the end of the first or last line of the buffer,
this dired-sidebar invocation is hidden."
(interactive)
(cond ((first-line-p)
(if (eolp)
(dired-sidebar-toggle-sidebar)
(hact 'link-to-directory default-directory)))
((and (last-line-p) (eolp))
(dired-sidebar-toggle-sidebar))
((eolp)
(funcall (if assist-flag assist-key-eol-function action-key-eol-function)))
(t (let ((file (dired-get-file-for-visit)))
(if (and dired-sidebar-cycle-subtree-on-click
(file-directory-p file)
(not (string-suffix-p "." file)))
(hact 'dired-sidebar-subtree-toggle)
(hact 'dired-sidebar-find-file file))))))
(provide 'hui-dired-sidebar)
;;; hui-dired-sidebar.el ends here
|