Skip to content

Commit

Permalink
Cleaning up naming to align with desired package name.
Browse files Browse the repository at this point in the history
  • Loading branch information
chaosemer committed Nov 21, 2023
1 parent 78c0bb5 commit 0b517bf
Showing 1 changed file with 28 additions and 19 deletions.
47 changes: 28 additions & 19 deletions window-tool-bar-mode.el → window-tool-bar.el
Original file line number Diff line number Diff line change
@@ -1,32 +1,37 @@
;;; -*- lexical-binding: t -*-

Check failure on line 1 in window-tool-bar.el

View workflow job for this annotation

GitHub Actions / test (29.1, true)

"Version:" or "Package-Version:" header is missing. MELPA will handle this, but other archives will not.

Check failure on line 1 in window-tool-bar.el

View workflow job for this annotation

GitHub Actions / test (29.1, true)

Package should have a ;;; Commentary section.

Check failure on line 1 in window-tool-bar.el

View workflow job for this annotation

GitHub Actions / test (29.1, true)

Package should have a Homepage or URL header.

Check failure on line 1 in window-tool-bar.el

View workflow job for this annotation

GitHub Actions / test (29.1, true)

package.el cannot parse this buffer: Package lacks a file header

Check failure on line 1 in window-tool-bar.el

View workflow job for this annotation

GitHub Actions / test (29.1, true)

You should depend on (emacs "24.1") if you need lexical-binding.
;;;
;;; TODO:
;;; * Add a bit more documentation.
;;; * Upload to github, internal git repo, and MELPA.
;;;; For 1.0
;;; * Make disabled properties display better (no mouse over)
;;; * Play with this on for a bit.
;;; * Upload to MELPA.

;;;; For 2.0
;;; * Properly support button labels
;;; * Make this work on non-graphical frames.
;;; * Add customization option: ignore-default-tool-bar-map
;;; * Make disabled properties display better (no mouse over)
;;; * Add utility function to clean up Emacs toolbars (Info, grep)
;;;
;;; * Add a bit more documentation.
;;; * Add customization option: ignore-default-tool-bar-map
;;; * Make tab-line dragging resize the window
(require 'tab-line)

Check failure on line 17 in window-tool-bar.el

View workflow job for this annotation

GitHub Actions / test (29.1, true)

You should depend on (emacs "27.1") if you need ‘tab-line’.

(defun tab-line-from-tool-bar ()
;;;###autoload
(defun window-tool-bar-string ()
(let ((toolbar-menu (cdr (keymap-global-lookup "<tool-bar>"))))

Check failure on line 21 in window-tool-bar.el

View workflow job for this annotation

GitHub Actions / test (29.1, true)

You should depend on (emacs "29.1") or the compat package if you need ‘keymap-global-lookup’.
(mapconcat #'tab-line-convert-keymap-entry toolbar-menu " ")))
(mapconcat #'window-tool-bar--keymap-entry-to-string toolbar-menu " ")))

(defun tab-line-convert-keymap-entry (menu-item)
(defun window-tool-bar--keymap-entry-to-string (menu-item)
"Convert MENU-ITEM into a (propertized) string representation."
(pcase menu-item

Check failure on line 26 in window-tool-bar.el

View workflow job for this annotation

GitHub Actions / test (29.1, true)

You should depend on (emacs "24.1") if you need ‘pcase’.
(`(,key menu-item ,name . ,props)

Check failure on line 27 in window-tool-bar.el

View workflow job for this annotation

GitHub Actions / test (29.1, true)

Unused lexical variable ‘props’
;; Normal menu item, turn into tab-line-button
;; Normal menu item, turn into propertized string button
(let ((str (format "[%s]" name)))
(setq str (propertize str
'mouse-face 'tab-line-highlight
'keymap (define-keymap
"<follow-link>" 'mouse-face
"<tab-line> <mouse-2>" #'tlftb--call-button)))
"<tab-line> <mouse-2>" #'window-tool-bar--call-button)))
(when-let ((spec (plist-get menu-item :image)))
(setq str (propertize str
'display spec)))
Expand All @@ -39,7 +44,7 @@
(`(,_ "--")
"|")))

(defun tlftb--call-button ()
(defun window-tool-bar--call-button ()
"Call the button that was clicked on in the tab line."
(interactive)
(when (mouse-event-p last-command-event)
Expand All @@ -50,18 +55,22 @@
(cmd (lookup-key global-map (vector 'tool-bar key))))
(call-interactively cmd))))))

(define-minor-mode tab-line-from-tool-bar-mode
;;;###autoload
(define-minor-mode window-tool-bar-mode
"Toggle display of the toolbar in the tab line of the current buffer."
:lighter nil
(if (and tab-line-from-tool-bar-mode
(if (and window-tool-bar-mode
(not (eq tool-bar-map (default-value 'tool-bar-map))))
(setq tab-line-format '(:eval (tab-line-from-tool-bar)))
(setq tab-line-format '(:eval (window-tool-bar-string)))
(setq tab-line-format nil)))

(defun tab-line-from-tool-bar--turn-on ()
(tab-line-from-tool-bar-mode 1))
(defun window-tool-bar--turn-on ()
(window-tool-bar-mode 1))

;;;###autoload
(define-globalized-minor-mode global-window-tool-bar-mode

Check failure on line 71 in window-tool-bar.el

View workflow job for this annotation

GitHub Actions / test (29.1, true)

defcustom for ‘global-window-tool-bar-mode’ fails to specify containing group
window-tool-bar-mode window-tool-bar--turn-on
(add-hook 'isearch-mode-hook #'window-tool-bar--turn-on)
(add-hook 'isearch-mode-end-hook #'window-tool-bar--turn-on))

(define-globalized-minor-mode global-tab-line-from-tool-bar-mode
tab-line-from-tool-bar-mode tab-line-from-tool-bar--turn-on
(add-hook 'isearch-mode-hook #'tab-line-from-tool-bar--turn-on)
(add-hook 'isearch-mode-end-hook #'tab-line-from-tool-bar--turn-on))
(provide 'window-tool-bar)

0 comments on commit 0b517bf

Please sign in to comment.