diff --git a/code/elpa/archives/melpa/archive-contents b/code/elpa/archives/melpa/archive-contents index af7c952..60c4a8b 100644 --- a/code/elpa/archives/melpa/archive-contents +++ b/code/elpa/archives/melpa/archive-contents @@ -1416,7 +1416,7 @@ (evalator-clojure . [(20160208 2148) ((cider (0 10 0)) (evalator (1 0 0))) "Clojure evaluation context for evalator via CIDER." tar ((:commit . "caa4e0a137bdfada86593128a654e16aa617ad50") (:authors ("Sean Irby")) (:maintainer "Sean Irby" . "sean.t.irby@gmail.com") (:keywords "languages" "clojure" "cider" "helm") (:url . "http://www.github.com/seanirby/evalator-clojure"))]) (eve-mode . [(20170822 2231) ((emacs (25)) (polymode (1 0)) (markdown-mode (2 0))) "Major mode for editing Eve documents." single ((:commit . "a4661114d9c18725691b76321d72167ca5a9070a") (:authors ("Joshua Cole" . "joshuafcole@gmail.com")) (:maintainer "Joshua Cole" . "joshuafcole@gmail.com") (:keywords "languages" "wp" "tools") (:url . "https://github.com/witheve/emacs-eve-mode"))]) (everlasting-scratch . [(20230105 507) ((emacs (25 1))) "The *scratch* that lasts forever" single ((:commit . "1b7dac779501dcd988552aa6455a5be89e8b0562") (:authors ("Huming Chen" . "chenhuming@gmail.com")) (:maintainer "Huming Chen" . "chenhuming@gmail.com") (:keywords "convenience" "tool") (:url . "https://github.com/beacoder/everlasting-scratch"))]) - (evil . [(20230322 1818) ((emacs (24 1)) (goto-chg (1 6)) (cl-lib (0 5))) "Extensible Vi layer for Emacs." tar ((:commit . "c61bc34b40f1f0605a999e874e837d1e8bda85af") (:maintainer "Tom Dalziel" . "tom.dalziel@gmail.com") (:keywords "emulations") (:url . "https://github.com/emacs-evil/evil"))]) + (evil . [(20230408 1154) ((emacs (24 1)) (goto-chg (1 6)) (cl-lib (0 5))) "Extensible Vi layer for Emacs." tar ((:commit . "de07e9a59231d280166c03e05407dcc1e5aed112") (:maintainer "Tom Dalziel" . "tom.dalziel@gmail.com") (:keywords "emulations") (:url . "https://github.com/emacs-evil/evil"))]) (evil-anzu . [(20220911 1939) ((evil (1 0 0)) (anzu (0 46))) "anzu for evil-mode" single ((:commit . "d1e98ee6976437164627542909a25c6946497899") (:authors ("Syohei YOSHIDA" . "syohex@gmail.com") ("Fredrik Bergroth" . "fbergroth@gmail.com")) (:maintainer "Syohei YOSHIDA" . "syohex@gmail.com") (:url . "https://github.com/syohex/emacs-evil-anzu"))]) (evil-args . [(20220125 1626) ((evil (1 0 8))) "Motions and text objects for delimited arguments in Evil." single ((:commit . "2671071a4a57eaee7cc8c27b9e4b6fc60fd2ccd3") (:authors ("Connor Smith" . "wconnorsmith@gmail.com")) (:maintainer "Connor Smith" . "wconnorsmith@gmail.com") (:keywords "evil" "vim-emulation") (:url . "http://github.com/wcsmith/evil-args"))]) (evil-avy . [(20150908 748) ((emacs (24 1)) (cl-lib (0 5)) (avy (0 3 0)) (evil (1 2 3))) "set-based completion" single ((:commit . "2dd955cc3ecaa7ddeb67b295298abdc6d16dd3a5") (:authors ("Yufan Lou" . "loganlyf@gmail.com")) (:maintainer "Yufan Lou" . "loganlyf@gmail.com") (:keywords "point" "location" "evil" "vim") (:url . "https://github.com/louy2/evil-avy"))]) @@ -1562,7 +1562,7 @@ (feebleline . [(20190822 1401) nil "Replace modeline with a slimmer proxy" single ((:commit . "b2f2db25cac77817bf0c49ea2cea6383556faea0") (:authors ("Benjamin Lindqvist" . "benjamin.lindqvist@gmail.com")) (:maintainer "Benjamin Lindqvist" . "benjamin.lindqvist@gmail.com") (:url . "https://github.com/tautologyclub/feebleline"))]) (feed-discovery . [(20200714 1118) ((emacs (25 1)) (dash (2 16 0))) "Discover feed url by RSS/Atom autodiscovery" single ((:commit . "3812439c845c184eaf164d3ac8935de135259855") (:authors ("Hiroki YAMAKAWA" . "s06139@gmail.com")) (:maintainer "Hiroki YAMAKAWA" . "s06139@gmail.com") (:url . "https://github.com/HKey/feed-discovery"))]) (feline . [(20230315 1821) ((emacs (28 1))) "A modeline with very little" single ((:commit . "3f9247f48058285d3e03957680e011ecf58d6feb") (:authors ("chee" . "emacs@chee.party")) (:maintainer "chee" . "emacs@chee.party") (:url . "https://opensource.chee.party/chee/feline-mode"))]) - (fennel-mode . [(20230408 619) ((emacs (26 1))) "A major-mode for editing Fennel code" tar ((:commit . "dd2d0845cd8f21f6487c4e8ca5ea104d1fcba11a") (:authors ("Phil Hagelberg")) (:maintainer "Phil Hagelberg") (:keywords "languages" "tools") (:url . "https://git.sr.ht/~technomancy/fennel-mode"))]) + (fennel-mode . [(20230408 1312) ((emacs (26 1))) "A major-mode for editing Fennel code" tar ((:commit . "d4e7226c34365101f02d9783d6d4b16c5014d279") (:authors ("Phil Hagelberg")) (:maintainer "Phil Hagelberg") (:keywords "languages" "tools") (:url . "https://git.sr.ht/~technomancy/fennel-mode"))]) (fetch . [(20131201 730) nil "Fetch and unpack resources" single ((:commit . "3f2793afcbbc32f320e572453166f9354ecc6d06") (:authors ("Christian 'crshd' Brassat" . "christian.brassat@gmail.com")) (:maintainer "Christian 'crshd' Brassat" . "christian.brassat@gmail.com") (:url . "https://github.com/crshd/fetch.el"))]) (ffmpeg-player . [(20220704 641) ((emacs (24 4)) (s (1 12 0)) (f (0 20 0))) "Play video using ffmpeg" single ((:commit . "2c41d715b012f399e661a816376824a8dea0b941") (:authors ("Shen, Jen-Chieh" . "jcs090218@gmail.com")) (:maintainer "Shen, Jen-Chieh" . "jcs090218@gmail.com") (:keywords "multimedia" "video" "ffmpeg" "buffering" "images") (:url . "https://github.com/jcs-elpa/ffmpeg-player"))]) (ffmpeg-utils . [(20230305 709) ((emacs (25 1)) (alert (1 2)) (transient (0 1 0))) "FFmpeg command utilities wrappers" single ((:commit . "064d61527bc6b6a1d0fb0065f8a7bae3bbd4cefc") (:keywords "multimedia") (:url . "https://repo.or.cz/ffmpeg-utils.git"))]) @@ -3088,7 +3088,7 @@ (math-symbol-lists . [(20220828 2047) nil "Lists of Unicode math symbols and latex commands" tar ((:commit . "ac3eb053d3b576fcdd192b0ac6ad5090ea3a7079") (:authors ("Vitalie Spinu" . "spinuvit@gmail.com")) (:maintainer "Vitalie Spinu" . "spinuvit@gmail.com") (:keywords "unicode" "symbols" "mathematics") (:url . "https://github.com/vspinu/math-symbol-lists"))]) (math-symbols . [(20201005 2313) nil "Math Symbol Input methods and conversion tools" tar ((:commit . "091b81cb40ceaff97614999ffe85b572ace182f0") (:authors ("KAWABATA, Taichi ")) (:maintainer "KAWABATA, Taichi ") (:keywords "i18n" "languages" "tex") (:url . "https://github.com/kawabata/math-symbols"))]) (math-tex-convert . [(20221210 1937) ((emacs (26 1)) (math-symbol-lists (1 3)) (auctex (12 1))) "Convert LaTeX macros to unicode and back" tar ((:commit . "8b174d05e8e5269322a1ee90f94cf1ed018d4976") (:authors ("Enrico Flor" . "enrico@eflor.net")) (:maintainer "Enrico Flor" . "enrico@eflor.net") (:url . "https://github.com/enricoflor/math-tex-convert"))]) - (matlab-mode . [(20230120 1938) nil "Major mode for MATLAB(R) dot-m files" tar ((:commit . "4cf540990f1f568c513162a0103b2b00c3d1ae43"))]) + (matlab-mode . [(20230408 1210) nil "Major mode for MATLAB(R) dot-m files" tar ((:commit . "bda900fd75ee2e507f56e411f54dc1512675559f"))]) (maude-mode . [(20220419 1454) ((emacs (25))) "Emacs mode for the programming language Maude" single ((:commit . "68de3c11ae16c409afa74516aaf465996d1a9e59") (:authors ("Ellef Gjelstad ")) (:maintainer "Rudi Schlatte" . "rudi@constantly.at") (:keywords "languages" "maude") (:url . "https://github.com/rudi/abs-mode"))]) (maven-test-mode . [(20141220 557) ((s (1 9)) (emacs (24))) "Utilities for navigating test files and running maven test tasks." single ((:commit . "a19151861df2ad8ae4880a2e7c86ddf848cb569a") (:authors ("Renan Ranelli")) (:maintainer "Renan Ranelli") (:keywords "java" "maven" "test") (:url . "http://github.com/rranelli/maven-test-mode"))]) (maxframe . [(20170120 1705) nil "maximize the emacs frame based on display size" single ((:commit . "13bda6dd9f1d96aa4b9dd9957a26cefd399a7772") (:authors ("Ryan McGeary")) (:maintainer "Ryan McGeary") (:keywords "display" "frame" "window" "maximize"))]) @@ -4283,7 +4283,7 @@ (regex-tool . [(20170104 1918) nil "A regular expression evaluation tool for programmers" single ((:commit . "0b4a0111143c88ef94bec56624cb2e00c1a054e6") (:authors ("John Wiegley" . "johnw@newartisans.com")) (:maintainer "John Wiegley" . "johnw@newartisans.com") (:keywords "regex" "languages" "programming" "development") (:url . "http://www.newartisans.com/"))]) (region-bindings-mode . [(20140407 2214) nil "Enable custom bindings when mark is active." single ((:commit . "3fa5dbdbd7c000bebff6d9d14a4be326ec24b6fc") (:authors ("Fabián E. Gallina" . "fabian@anue.biz")) (:maintainer "Fabián E. Gallina" . "fabian@anue.biz") (:keywords "convenience") (:url . "https://github.com/fgallina/region-bindings-mode"))]) (region-convert . [(20210519 1655) ((emacs (24 3))) "Convert string in region by Lisp function" single ((:commit . "cb3ab0417d7b74e5edd34bf23a70737fc7bf1d3a") (:authors ("USAMI Kenta" . "tadsan@zonu.me")) (:maintainer "USAMI Kenta" . "tadsan@zonu.me") (:keywords "region" "convenience") (:url . "https://github.com/zonuexe/right-click-context"))]) - (region-occurrences-highlighter . [(20230221 1803) ((emacs (24))) "Mark occurrences of current region (selection)." single ((:commit . "9c2a3193ccf32f8fa48578a6b8826b2959dac120") (:authors ("Álvaro González Sotillo" . "alvarogonzalezsotillo@gmail.com")) (:maintainer "Álvaro González Sotillo" . "alvarogonzalezsotillo@gmail.com") (:keywords "convenience") (:url . "https://github.com/alvarogonzalezsotillo/region-occurrences-highlighter"))]) + (region-occurrences-highlighter . [(20230408 1404) ((emacs (24))) "Mark occurrences of current region (selection)." single ((:commit . "3fbac20154035d75238facbc3b881ab3b47ab711") (:authors ("Álvaro González Sotillo" . "alvarogonzalezsotillo@gmail.com")) (:maintainer "Álvaro González Sotillo" . "alvarogonzalezsotillo@gmail.com") (:keywords "convenience") (:url . "https://github.com/alvarogonzalezsotillo/region-occurrences-highlighter"))]) (region-state . [(20181205 1746) nil "Show the number of chars/lines or rows/columns in the region" single ((:commit . "f9e3926036a7c261b20bad9bf46f68ead8c15024") (:authors ("Chunyang Xu" . "mail@xuchunyang.me")) (:maintainer "Chunyang Xu" . "mail@xuchunyang.me") (:keywords "convenience") (:url . "https://github.com/xuchunyang/region-state.el"))]) (register-channel . [(20210120 1618) nil "Jump around fast using registers" single ((:commit . "ed7f563e92170b758dc878fcb5df88d46d5d44cc") (:authors ("Yang Zhao" . "YangZhao11@users.noreply.github.com")) (:maintainer "Yang Zhao" . "YangZhao11@users.noreply.github.com") (:keywords "convenience"))]) (register-quicknav . [(20200524 2006) ((emacs (25 3))) "Quickly jump to next/previous register" single ((:commit . "c15ea92b0946c28b3f14986d42b15b0b534aa6a2") (:authors ("tastytea" . "tastytea@tastytea.de")) (:maintainer "tastytea" . "tastytea@tastytea.de") (:keywords "convenience") (:url . "https://schlomp.space/tastytea/register-quicknav"))]) diff --git a/code/elpa/centaur-tabs-20230109.457/centaur-tabs-autoloads.el b/code/elpa/centaur-tabs-20230109.457/centaur-tabs-autoloads.el new file mode 100644 index 0000000..17f015b --- /dev/null +++ b/code/elpa/centaur-tabs-20230109.457/centaur-tabs-autoloads.el @@ -0,0 +1,103 @@ +;;; centaur-tabs-autoloads.el --- automatically extracted autoloads -*- lexical-binding: t -*- +;; +;;; Code: + +(add-to-list 'load-path (directory-file-name + (or (file-name-directory #$) (car load-path)))) + + +;;;### (autoloads nil "centaur-tabs" "centaur-tabs.el" (0 0 0 0)) +;;; Generated autoloads from centaur-tabs.el + +(autoload 'centaur-tabs-local-mode "centaur-tabs" "\ +Toggle local display of the tab bar. +With prefix argument ARG, turn on if positive, otherwise off. +Returns non-nil if the new state is enabled. +When turned on, if a local header line is shown, it is hidden to show +the tab bar. The tab bar is locally hidden otherwise. When turned +off, if a local header line is hidden or the tab bar is locally +hidden, it is shown again. Signal an error if Centaur-Tabs mode is off. + +\(fn &optional ARG)" t nil) + +(defvar centaur-tabs-mode nil "\ +Non-nil if Centaur-Tabs mode is enabled. +See the `centaur-tabs-mode' command +for a description of this minor mode. +Setting this variable directly does not take effect; +either customize it (see the info node `Easy Customization') +or call the function `centaur-tabs-mode'.") + +(custom-autoload 'centaur-tabs-mode "centaur-tabs" nil) + +(autoload 'centaur-tabs-mode "centaur-tabs" "\ +Toggle display of a tab bar in the header line. +With prefix argument ARG, turn on if positive, otherwise off. +Returns non-nil if the new state is enabled. + +\\{centaur-tabs-mode-map} + +\(fn &optional ARG)" t nil) + +(register-definition-prefixes "centaur-tabs" '("centaur-tabs-")) + +;;;*** + +;;;### (autoloads nil "centaur-tabs-elements" "centaur-tabs-elements.el" +;;;;;; (0 0 0 0)) +;;; Generated autoloads from centaur-tabs-elements.el + +(register-definition-prefixes "centaur-tabs-elements" '("cent")) + +;;;*** + +;;;### (autoloads nil "centaur-tabs-functions" "centaur-tabs-functions.el" +;;;;;; (0 0 0 0)) +;;; Generated autoloads from centaur-tabs-functions.el + +(autoload 'centaur-tabs-backward "centaur-tabs-functions" "\ +Select the previous available tab. +Depend on the setting of the option `centaur-tabs-cycle-scope'." t nil) + +(autoload 'centaur-tabs-forward "centaur-tabs-functions" "\ +Select the next available tab. +Depend on the setting of the option `centaur-tabs-cycle-scope'." t nil) + +(autoload 'centaur-tabs-backward-group "centaur-tabs-functions" "\ +Go to selected tab in the previous available group." t nil) + +(autoload 'centaur-tabs-forward-group "centaur-tabs-functions" "\ +Go to selected tab in the next available group." t nil) + +(autoload 'centaur-tabs-backward-tab "centaur-tabs-functions" "\ +Select the previous visible tab." t nil) + +(autoload 'centaur-tabs-forward-tab "centaur-tabs-functions" "\ +Select the next visible tab." t nil) + +(register-definition-prefixes "centaur-tabs-functions" '("centaur-tabs-")) + +;;;*** + +;;;### (autoloads nil "centaur-tabs-interactive" "centaur-tabs-interactive.el" +;;;;;; (0 0 0 0)) +;;; Generated autoloads from centaur-tabs-interactive.el + +(autoload 'centaur-tabs-counsel-switch-group "centaur-tabs-interactive" "\ +Display a list of current buffer groups using Counsel." t nil) + +(register-definition-prefixes "centaur-tabs-interactive" '("centaur-tabs-")) + +;;;*** + +;;;### (autoloads nil nil ("centaur-tabs-pkg.el") (0 0 0 0)) + +;;;*** + +;; Local Variables: +;; version-control: never +;; no-byte-compile: t +;; no-update-autoloads: t +;; coding: utf-8 +;; End: +;;; centaur-tabs-autoloads.el ends here diff --git a/code/elpa/centaur-tabs-20230109.457/centaur-tabs-elements.el b/code/elpa/centaur-tabs-20230109.457/centaur-tabs-elements.el new file mode 100644 index 0000000..ff70386 --- /dev/null +++ b/code/elpa/centaur-tabs-20230109.457/centaur-tabs-elements.el @@ -0,0 +1,822 @@ +;;; centaur-tabs-elements.el --- centaur-tabs visual components and customizations -*- lexical-binding: t; -*- + +;; Copyright (C) 2019-2020 Emmanuel Bustos +;; Package-Requires: ((emacs "24.4") (powerline "2.4") (cl-lib "0.5")) + +;; This file is not part of GNU Emacs. + +;; +;; This program is free software; you can redistribute it and/or +;; modify it under the terms of the GNU General Public License as +;; published by the Free Software Foundation; either version 2, or +;; (at your option) any later version. +;; +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +;; General Public License for more details. +;; +;; You should have received a copy of the GNU General Public License +;; along with this program; see the file COPYING. If not, write to +;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth +;; Floor, Boston, MA 02110-1301, USA. +;; +;;; Commentary: +;; This file contains the visual components of centaur-tabs + +;;; Code: +;; +;;; Requires +;; +(require 'color) +(require 'powerline) +;;; Faces +;; +(defface centaur-tabs-default + '((t + (:background "black" :foreground "black"))) + "Default face used in the tab bar." + :group 'centaur-tabs) + +(defface centaur-tabs-unselected + '((t + (:background "#3D3C3D" :foreground "grey50"))) + "Face used for unselected tabs." + :group 'centaur-tabs) + +(defface centaur-tabs-selected + '((t (:background "#31343E" :foreground "white"))) + "Face used for the selected tab." + :group 'centaur-tabs) + +(defface centaur-tabs-unselected-modified + '((t + (:background "#3D3C3D" :foreground "grey50"))) + "Face used for unselected-modified tabs." + :group 'centaur-tabs) + +(defface centaur-tabs-selected-modified + '((t (:background "#31343E" :foreground "white"))) + "Face used for the selected-modified tab." + :group 'centaur-tabs) + +(defface centaur-tabs-close-unselected + '((t + (:inherit centaur-tabs-unselected))) + "Face used for unselected close button." + :group 'centaur-tabs) + +(defface centaur-tabs-close-selected + '((t (:inherit centaur-tabs-selected))) + "Face used for selected close button." + :group 'centaur-tabs) + +(defface centaur-tabs-name-mouse-face + '((t nil)) + "Face used for tab name when hovered with the mouse." + :group 'centaur-tabs) + +(defface centaur-tabs-close-mouse-face + '((t (:inherit underline))) + "Face used for close button when hovered with the mouse." + :group 'centaur-tabs) + +(defface centaur-tabs-modified-marker-selected + `((t (:inherit centaur-tabs-selected))) + "Face used for selected modified marker." + :group 'centaur-tabs) + +(defface centaur-tabs-modified-marker-unselected + `((t (:inherit centaur-tabs-unselected))) + "Face used for unselected modified marker." + :group 'centaur-tabs) + +(defface centaur-tabs-active-bar-face + '((t (:background "cyan"))) + "Face used for selected tab bar." + :group 'centaur-tabs) + +(defface centaur-tabs-jump-identifier-selected + '((t (:inherit centaur-tabs-modified-marker-selected :weight extra-bold))) + "Face used for selected tab identifiers when centaur-tabs-ace-jump is invoked." + :group 'centaur-tabs) + +(defface centaur-tabs-jump-identifier-unselected + '((t (:inherit centaur-tabs-modified-marker-unselected :weight extra-bold))) + "Face used for unselected tab identifiers when centaur-tabs-ace-jump is invoked." + :group 'centaur-tabs) + +(defface centaur-tabs-dim-buffer-face + '((t (:foreground "gray40"))) + "Face for the buffer when centaur-tabs-ace-jump is invoked.") + +;;; Tabs' display line +;; +(defvar centaur-tabs-display-line + (if (boundp 'tab-line-format) + 'tab-line + 'header-line)) + +(defvar centaur-tabs-display-line-format + (if (boundp 'tab-line-format) + 'tab-line-format + 'header-line-format)) + +;;; Tabs' characteristics +;; +(defcustom centaur-tabs-style "bar" + "The style of tab." + :group 'centaur-tabs + :type 'string) + +(defcustom centaur-tabs-label-fixed-length 0 + "Fixed length of label. Set to 0 if dynamic." + :group 'centaur-tabs + :type 'int) + +(defcustom centaur-tabs-background-color + (face-background 'centaur-tabs-default nil 'default) + "*Background color of the tab bar. +By default, use the background color specified for the +`centaur-tabs-default' face (or inherited from another face), or the +background color of the `default' face otherwise." + :group 'centaur-tabs + :type 'face) + +(defcustom centaur-tabs-height 22 + "The height of tab." + :group 'centaur-tabs + :type 'int) + +(defcustom centaur-tabs-bar-height (+ 8 centaur-tabs-height) + "The height of bar." + :group 'centaur-tabs + :type 'int) + +(defcustom centaur-tabs-mouse-pointer 'hand + "Cursor to display when hovering the tabs. +Default is 'hand. The following scopes are possible: +- arrow +- hand +- vdrag +- hdrag +- modeline +- hourglass" + :group 'centaur-tabs + :type 'variable) + +;;; Icons +;; +(defcustom centaur-tabs-set-icons nil + "When non nil, display an icon from all-the-icons alongside the tab name." + :group 'centaur-tabs + :type 'boolean) + +(defvar centaur-tabs-icon-scale-factor + 1.0 + "The base scale factor for the `height' face property of tab icons.") + +(defvar centaur-tabs-icon-v-adjust + 0.01 + "The vertical adjust for tab icons.") + +(defcustom centaur-tabs-gray-out-icons nil + "When non nil, enable gray icons for unselected buffer." + :group 'centaur-tabs + :type '(choice :tag "Gray out icons for unselected..." + (const :tag "Buffer" buffer))) + +(defcustom centaur-tabs-plain-icons nil + "When non nil, tab icons' color will be the same as tabs' foreground color." + :group 'centaur-tabs + :type 'boolean) + +(defun centaur-tabs-icon (tab face selected) + "Generate all-the-icons icon for TAB using FACE's background. +If icon gray out option enabled, gray out icon if not SELECTED." + (if (featurep 'all-the-icons) + (with-current-buffer (car tab) + (let* ((icon + (if (and (buffer-file-name) + (all-the-icons-auto-mode-match?)) + (all-the-icons-icon-for-file + (file-name-nondirectory (buffer-file-name)) + :v-adjust centaur-tabs-icon-v-adjust + :height centaur-tabs-icon-scale-factor) + (all-the-icons-icon-for-mode + major-mode + :v-adjust centaur-tabs-icon-v-adjust + :height centaur-tabs-icon-scale-factor))) + (background (face-background face nil 'default)) + (inactive (cond ((and (not selected) + (eq centaur-tabs-gray-out-icons 'buffer)) + (face-foreground 'mode-line-inactive nil 'default)) + (centaur-tabs-plain-icons + (face-foreground 'centaur-tabs-selected nil 'default)) + (t 'unspecified))) + (underline (and (eq (if (display-graphic-p) centaur-tabs-set-bar) 'under) + (face-attribute face :underline))) + (overline (and (eq (if (display-graphic-p) centaur-tabs-set-bar) 'over) + (face-attribute face :overline)))) + (if (stringp icon) + (progn + (propertize icon 'face `(:inherit ,(get-text-property 0 'face icon) + :foreground ,inactive + :background ,background + :underline ,underline + :overline ,overline))) + ""))) + "")) + +;;; Ace-window style tab switching +;; +(defcustom centaur-tabs-show-jump-identifier 'prompted + "Whether to show the tab identifier for centaur-tabs-ace-jump. +It has 3 options: +- 'nil, never show the jump identifier. +- 'prompted, only show it when using centaur-tabs-ace-jump. +- 'always, always show it regardless of the status." + :group 'centaur-tabs + :type '(choice :tag "show identifier when..." + (const :tag "Never" nil) + (const :tag "Only when prompted" prompted) + (const :tag "Always" always))) + +(defcustom centaur-tabs-ace-jump-dim-buffer t + "Whether to dim the current buffer when centaur-ace-jump is activated.") + +(defvar centaur-tabs-ace-jump-keys + '(?1 ?2 ?3 ?4 ?5 ?6 ?7 ?8 ?9) + "Buffer jump keys used by centaur-tabs-ace-jump.") + +(defvar centuar-tabs-ace-dispatch-alist + '((?q exit "Exit") + (?\C-g exit "Exit") + (?j jump-to-tab "Jump to tab") + (?x close-tab "Close tab") + (?s swap-tab "Swap tab") + (?\[ backward-group "Previous group") + (?\] forward-group "Next group") + (?? show-help "Show dispatch help")) + "Action keys used by centaur-tabs-ace-jump. +The value of each element must be in the form: +\(key keyword docstring), where keyword must be one of the follows: +\(exit, jump-to-tab, close-tab, swap-tab, backward-group, +forward-group, show-help).") + +;;; Close buttons, modified marker and edges' margins +;; +(defcustom centaur-tabs-set-close-button t + "When non nil, display a clickable close button on the right side of the tabs." + :group 'centaur-tabs + :type 'boolean) + +(defcustom centaur-tabs-set-left-close-button nil + "When non nil, display a clickable close button on the left side of the tabs." + :group 'centaur-tabs + :type 'boolean) + +(defcustom centaur-tabs-close-button (make-string 1 #x00D7) + "Display appearance of the close buttons, if enabled." + :group 'centaur-tabs + :type 'string) + +(defcustom centaur-tabs-set-modified-marker nil + "When non nil, display a marker when the buffer is modified." + :group 'centaur-tabs + :type 'boolean) + +(defcustom centaur-tabs-modified-marker (make-string 1 #x23FA) + "Display appearance of the modified marker, if enabled." + :group 'centaur-tabs + :type 'string) + +(defcustom centaur-tabs-left-edge-margin " " + "Text to display at the left edge of the tabs, or nil for no added margin." + :group 'centaur-tabs + :type 'string) + +(defcustom centaur-tabs-right-edge-margin " " + "Text to display at the right edge of the tabs, or nil for no added margin." + :group 'centaur-tabs + :type 'string) + +;;; Selected tab bar +;; +(defcustom centaur-tabs-set-bar nil + "When non nil, display a bar to show the currently selected tab. +There are three options: +- 'left: displays the bar at the left of the currently selected tab. +- 'under: displays the bar under the currently selected tab. +- 'over: displays the bar over the currently selected tab." + :group 'centaur-tabs + :type '(choice :tag "Display bar at..." + (const :tag "Put bar on the left" left) + (const :tag "Put bar as an underline" under) + (const :tag "Put bar as an overline" over))) + +(defun centaur-tabs--make-xpm (face width height) + "Create an XPM bitmap via FACE WIDTH and HEIGHT. +Taken from `doom-modeline'." + (when (and (display-graphic-p) + (image-type-available-p 'xpm)) + (propertize + " " 'display + (let ((data (make-list height (make-list width 1))) + (color (or (face-background face nil t) "None"))) + (ignore-errors + (create-image + (concat + (format + "/* XPM */\nstatic char * percent[] = {\n\"%i %i 2 1\",\n\". c %s\",\n\" c %s\"," + (length (car data)) (length data) color color) + (apply #'concat + (cl-loop with idx = 0 + with len = (length data) + for dl in data + do (cl-incf idx) + collect + (concat + "\"" + (cl-loop for d in dl + if (= d 0) collect (string-to-char " ") + else collect (string-to-char ".")) + (if (eq idx len) "\"};" "\",\n"))))) + 'xpm t :ascent 'center)))))) + +(defvar centaur-tabs-active-bar + (centaur-tabs--make-xpm 'centaur-tabs-active-bar-face + 2 + centaur-tabs-bar-height)) + +;;; Navigation buttons +;; +(defcustom centaur-tabs-show-navigation-buttons nil + "When non-nil, show the buttons for backward/forward tabs." + :group 'centaur-tabs + :type 'boolean) + +(defcustom centaur-tabs-down-tab-text " ▾ " + "Text icon to show in the down button tab." + :group 'centaur-tabs + :type 'string) + +(defcustom centaur-tabs-backward-tab-text " ⏴ " + "Text icon to show in the backward button tab." + :group 'centaur-tabs + :type 'string) + +(defcustom centaur-tabs-forward-tab-text " ⏵ " + "Text icon to show in the forward button tab." + :group 'centaur-tabs + :type 'string) + +(defcustom centaur-tabs-show-count nil + "When non-nil, show the current index and count of tabs in the current group." + :group 'centaur-tabs + :type 'boolean) + +;;; New tab button +;; +(defcustom centaur-tabs-show-new-tab-button t + "When non-nil, show the button to create a new tab." + :group 'centaur-tabs + :type 'boolean) + +(defcustom centaur-tabs-new-tab-text " + " + "Text icon to show in the new-tab button." + :group 'centaur-tabs + :type 'string) + +;;; Separators +;; +(defvar centaur-tabs-style-left nil) +(defvar centaur-tabs-style-right nil) + +(defvar ns-use-srgb-colorspace) + +(defvar centaur-tabs-image-apple-rgb + (and (eq (window-system) 'ns) + ns-use-srgb-colorspace + (< 11 + (string-to-number + (and (string-match "darwin\\([0-9]+\\)" system-configuration) + (match-string-no-properties 1 system-configuration))))) + "Boolean variable to determine whether to use Apple RGB colorspace. +used to render images. + +t on macOS 10.7+ and `ns-use-srgb-colorspace' is t, nil otherwise. + +This variable is automatically set, there's no need to modify it.") + +(defun centaur-tabs-separator-interpolate (color1 color2) + "Interpolate between COLOR1 and COLOR2. + +COLOR1 and COLOR2 must be supplied as hex strings with a leading #." + (let* ((c1 (color-name-to-rgb color1)) + (c2 (color-name-to-rgb color2)) + (red (/ (+ (nth 0 c1) (nth 0 c2)) 2)) + (green (/ (+ (nth 1 c1) (nth 1 c2)) 2)) + (blue (/ (+ (nth 2 c1) (nth 2 c2)) 2))) + (color-rgb-to-hex red green blue))) + +(defun centaur-tabs-separator-color-xyz-to-apple-rgb (X Y Z) + "Convert CIE X Y Z colors to Apple RGB color space." + (let ((r (+ (* 3.2404542 X) (* -1.5371385 Y) (* -0.4985314 Z))) + (g (+ (* -0.9692660 X) (* 1.8760108 Y) (* 0.0415560 Z))) + (b (+ (* 0.0556434 X) (* -0.2040259 Y) (* 1.0572252 Z)))) + (list (expt r (/ 1.8)) (expt g (/ 1.8)) (expt b (/ 1.8))))) + +(defun centaur-tabs-separator-color-srgb-to-apple-rgb (red green blue) + "Convert RED GREEN BLUE colors from sRGB color space to Apple RGB. +RED, GREEN and BLUE should be between 0.0 and 1.0, inclusive." + (apply #'centaur-tabs-separator-color-xyz-to-apple-rgb (color-srgb-to-xyz red green blue))) + +(defun centaur-tabs-separator-hex-color (color) + "Get the hexadecimal value of COLOR." + (when color + (let ((srgb-color (color-name-to-rgb color))) + (if centaur-tabs-image-apple-rgb + (apply #'color-rgb-to-hex (apply #'centaur-tabs-separator-color-srgb-to-apple-rgb srgb-color)) + (apply #'color-rgb-to-hex srgb-color))))) + +(defun centaur-tabs-separator-pattern (lst) + "Turn LST into an infinite pattern." + (when lst + (let ((pattern (cl-copy-list lst))) + (setcdr (last pattern) pattern)))) + +(defun centaur-tabs-separator-pattern-to-string (pattern) + "Convert a PATTERN into a string that can be used in an XPM." + (concat "\"" (mapconcat #'number-to-string pattern "") "\",")) + +(defun centaur-tabs-separator-reverse-pattern (pattern) + "Reverse each line in PATTERN." + (cl-mapcar 'reverse pattern)) + +(defun centaur-tabs-separator-row-pattern (fill total &optional fade) + "Make a list that has FILL 0s out of TOTAL 1s with FADE 2s to the right of the fill." + (unless fade + (setq fade 0)) + (let ((fill (min fill total)) + (fade (min fade (max (- total fill) 0)))) + (append (make-list fill 0) + (make-list fade 2) + (make-list (- total fill fade) 1)))) + +(defun centaur-tabs-separator-pattern-bindings-body (patterns height-exp pattern-height-sym + second-pattern-height-sym) + "Create let-var bindings and a function body from PATTERNS. +The `car' and `cdr' parts of the result can be passed to the +function `centaur-tabs-separator-wrap-defun' as its `let-vars' +and `body' arguments,respectively. HEIGHT-EXP is an expression + calculating the image height and it should contain a free variable `height'. +PATTERN-HEIGHT-SYM and SECOND-PATTERN-HEIGHT-SYM are symbols used +for let-var binding variables." + (let* ((pattern (centaur-tabs-separator-pattern (cl-mapcar 'centaur-tabs-separator-pattern-to-string (car patterns)))) + (header (cl-mapcar 'centaur-tabs-separator-pattern-to-string (nth 1 patterns))) + (footer (cl-mapcar 'centaur-tabs-separator-pattern-to-string (nth 2 patterns))) + (second-pattern (centaur-tabs-separator-pattern (cl-mapcar 'centaur-tabs-separator-pattern-to-string (nth 3 patterns)))) + (center (cl-mapcar 'centaur-tabs-separator-pattern-to-string (nth 4 patterns))) + (reserve (+ (length header) (length footer) (length center)))) + (when pattern + (cons `((,pattern-height-sym (max (- ,height-exp ,reserve) 0)) + (,second-pattern-height-sym (/ ,pattern-height-sym 2)) + (,pattern-height-sym ,(if second-pattern `(ceiling ,pattern-height-sym 2) `,pattern-height-sym))) + (list (when header `(mapconcat 'identity ',header "")) + `(mapconcat 'identity + (cl-subseq ',pattern 0 ,pattern-height-sym) "") + (when center `(mapconcat 'identity ',center "")) + (when second-pattern + `(mapconcat 'identity + (cl-subseq ',second-pattern + 0 ,second-pattern-height-sym) "")) + (when footer `(mapconcat 'identity ',footer ""))))))) + +(defun centaur-tabs-separator-pattern-defun (name dir width &rest patterns) + "Create a powerline function of NAME in DIR with WIDTH for PATTERNS. + +PATTERNS is of the form (PATTERN HEADER FOOTER SECOND-PATTERN CENTER +PATTERN-2X HEADER-2X FOOTER-2X SECOND-PATTERN-2X CENTER-2X). +PATTERN is required, all other components are optional. +The first 5 components are for the standard resolution image. +The remaining ones are for the high resolution image where both +width and height are doubled. If PATTERN-2X is nil or not given, +then the remaining components are ignored and the standard +resolution image with magnification and interpolation will be +used in high resolution environments + +All generated functions generate the form: +HEADER +PATTERN ... +CENTER +SECOND-PATTERN ... +FOOTER + +PATTERN and SECOND-PATTERN repeat infinitely to fill the space needed to +generate a full height XPM. + +PATTERN, HEADER, FOOTER, SECOND-PATTERN, CENTER are of the form +\((COLOR ...) (COLOR ...) ...). + +COLOR can be one of 0, 1, or 2, where 0 is the source color, 1 is the +destination color, and 2 is the interpolated color between 0 and 1." + (when (eq dir 'right) + (setq patterns (cl-mapcar 'centaur-tabs-separator-reverse-pattern patterns))) + (let ((bindings-body (centaur-tabs-separator-pattern-bindings-body patterns + 'height + 'pattern-height + 'second-pattern-height)) + (bindings-body-2x (centaur-tabs-separator-pattern-bindings-body (nthcdr 5 patterns) + '(* height 2) + 'pattern-height-2x + 'second-pattern-height-2x))) + (centaur-tabs-separator-wrap-defun name dir width + (append (car bindings-body) (car bindings-body-2x)) + (cdr bindings-body) (cdr bindings-body-2x)))) + +(defun centaur-tabs-separator-background-color (face) + "Set the separator background color using FACE." + (face-attribute face + (if (face-attribute face :inverse-video nil 'default) + :foreground + :background) + nil + 'default)) + +(defun centaur-tabs-separator-wrap-defun (name dir width let-vars body &optional body-2x) + "Generate a powerline function of name NAME in dir DIR. +This is made with WIDTH using LET-VARS and BODY. +BODY-2X is an optional argument." + (let* ((src-face (if (eq dir 'left) 'face1 'face2)) + (dst-face (if (eq dir 'left) 'face2 'face1))) + `(defun ,(intern (format "powerline-%s-%s" name (symbol-name dir))) + (face1 face2 &optional height) + (when window-system + (unless height (setq height centaur-tabs-height)) + (let* ,(append `((color1 (when ,src-face + (centaur-tabs-separator-hex-color (centaur-tabs-separator-background-color ,src-face)))) + (color2 (when ,dst-face + (centaur-tabs-separator-hex-color (centaur-tabs-separator-background-color ,dst-face)))) + (colori (when (and color1 color2) (centaur-tabs-separator-interpolate color1 color2))) + (color1 (or color1 "None")) + (color2 (or color2 "None")) + (colori (or colori "None"))) + let-vars) + (apply #'create-image + ,(append `(concat (format "/* XPM */ static char * %s_%s[] = { \"%s %s 3 1\", \"0 c %s\", \"1 c %s\", \"2 c %s\"," + ,(replace-regexp-in-string "-" "_" name) + (symbol-name ',dir) + ,width + height + color1 + color2 + colori)) + body + '("};")) + 'xpm t + :ascent 'center + :face (when (and face1 face2) + ,dst-face) + ,(and body-2x + `(and (featurep 'mac) + (list :data-2x + ,(append `(concat (format "/* XPM */ static char * %s_%s_2x[] = { \"%s %s 3 1\", \"0 c %s\", \"1 c %s\", \"2 c %s\"," + ,(replace-regexp-in-string "-" "_" name) + (symbol-name ',dir) + (* ,width 2) + (* height 2) + color1 + color2 + colori)) + body-2x + '("};"))))))))))) + +(defun centaur-tabs-separator-alternate (dir) + "Generate an alternating pattern XPM function for DIR." + (centaur-tabs-separator-pattern-defun "alternate" dir 4 + '((2 2 1 1) + (0 0 2 2)) + nil nil nil nil + ;; 2x + '((2 2 2 2 1 1 1 1) + (2 2 2 2 1 1 1 1) + (0 0 0 0 2 2 2 2) + (0 0 0 0 2 2 2 2)))) + +(defun centaur-tabs-separator-bar (dir) + "Generate a bar XPM function for DIR." + (centaur-tabs-separator-pattern-defun "bar" dir 2 + '((2 2)))) + +(defun centaur-tabs-separator-box (dir) + "Generate a box XPM function for DIR." + (centaur-tabs-separator-pattern-defun "box" dir 2 + '((0 0) + (0 0) + (1 1) + (1 1)) + nil nil nil nil + ;; 2x + '((0 0 0 0) + (0 0 0 0) + (0 0 0 0) + (0 0 0 0) + (1 1 1 1) + (1 1 1 1) + (1 1 1 1) + (1 1 1 1)))) + +(defun centaur-tabs-separator-chamfer (dir) + "Generate a chamfer XPM function for DIR." + (centaur-tabs-separator-pattern-defun "chamfer" dir 3 + '((0 0 0)) + '((1 1 1) + (0 1 1) + (0 0 1)) + nil nil nil + ;; 2x + '((0 0 0 0 0 0)) + '((1 1 1 1 1 1) + (0 1 1 1 1 1) + (0 0 1 1 1 1) + (0 0 0 1 1 1) + (0 0 0 0 1 1) + (0 0 0 0 0 1)))) + +(defun centaur-tabs-separator-rounded (dir) + "Generate a rounded XPM function for DIR." + (centaur-tabs-separator-pattern-defun "rounded" dir 6 + '((0 0 0 0 0 0)) + '((2 1 1 1 1 1) + (0 0 2 1 1 1) + (0 0 0 0 1 1) + (0 0 0 0 2 1) + (0 0 0 0 0 1) + (0 0 0 0 0 2)) + nil nil nil + ;; 2x + '((0 0 0 0 0 0 0 0 0 0 0 0)) + '((1 1 1 1 1 1 1 1 1 1 1 1) + (0 0 2 1 1 1 1 1 1 1 1 1) + (0 0 0 0 1 1 1 1 1 1 1 1) + (0 0 0 0 0 0 1 1 1 1 1 1) + (0 0 0 0 0 0 0 2 1 1 1 1) + (0 0 0 0 0 0 0 0 1 1 1 1) + (0 0 0 0 0 0 0 0 0 1 1 1) + (0 0 0 0 0 0 0 0 0 0 1 1) + (0 0 0 0 0 0 0 0 0 0 1 1) + (0 0 0 0 0 0 0 0 0 0 2 1) + (0 0 0 0 0 0 0 0 0 0 0 1) + (0 0 0 0 0 0 0 0 0 0 0 1)))) + +(defun centaur-tabs-separator-slant (dir) + "Generate a slant XPM function for DIR." + (let* ((row-modifier (if (eq dir 'left) 'identity 'reverse))) + (centaur-tabs-separator-wrap-defun "slant" dir 'width + '((width (1- (ceiling height 2)))) + `((cl-loop for i from 0 to (1- height) + concat (centaur-tabs-separator-pattern-to-string (,row-modifier (centaur-tabs-separator-row-pattern (/ i 2) width))))) + `((cl-loop for i from 0 to (1- (* height 2)) + concat (centaur-tabs-separator-pattern-to-string (,row-modifier (centaur-tabs-separator-row-pattern (/ i 2) (* width 2))))))))) + +(defun centaur-tabs-separator-wave (dir) + "Generate a wave XPM function for DIR." + (centaur-tabs-separator-pattern-defun "wave" dir 11 + '((0 0 0 0 0 0 1 1 1 1 1)) + '((2 1 1 1 1 1 1 1 1 1 1) + (0 0 1 1 1 1 1 1 1 1 1) + (0 0 0 1 1 1 1 1 1 1 1) + (0 0 0 2 1 1 1 1 1 1 1) + (0 0 0 0 1 1 1 1 1 1 1) + (0 0 0 0 2 1 1 1 1 1 1) + (0 0 0 0 0 1 1 1 1 1 1) + (0 0 0 0 0 1 1 1 1 1 1) + (0 0 0 0 0 2 1 1 1 1 1)) + '((0 0 0 0 0 0 2 1 1 1 1) + (0 0 0 0 0 0 0 1 1 1 1) + (0 0 0 0 0 0 0 1 1 1 1) + (0 0 0 0 0 0 0 2 1 1 1) + (0 0 0 0 0 0 0 0 1 1 1) + (0 0 0 0 0 0 0 0 2 1 1) + (0 0 0 0 0 0 0 0 0 0 2)) + nil nil + ;; 2x + '((0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1)) + '((1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1) + (0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1) + (0 0 0 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1) + (0 0 0 0 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1) + (0 0 0 0 0 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1) + (0 0 0 0 0 0 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1) + (0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1) + (0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1) + (0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1) + (0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1) + (0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1) + (0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1) + (0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1) + (0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1) + (0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1) + (0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1) + (0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1) + (0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1)) + '((0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1) + (0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1) + (0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1) + (0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1) + (0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1) + (0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1) + (0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1) + (0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1) + (0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1) + (0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1) + (0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 1 1 1 1 1) + (0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 1 1 1 1) + (0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1) + (0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0)))) + +(defun centaur-tabs-separator-zigzag (dir) + "Generate a zigzag pattern XPM function for DIR." + (centaur-tabs-separator-pattern-defun "zigzag" dir 3 + '((1 1 1) + (0 1 1) + (0 0 1) + (0 0 0) + (0 0 1) + (0 1 1)) + nil nil nil nil + ;; 2x + '((1 1 1 1 1 1) + (0 1 1 1 1 1) + (0 0 1 1 1 1) + (0 0 0 1 1 1) + (0 0 0 0 1 1) + (0 0 0 0 0 1) + (0 0 0 0 0 0) + (0 0 0 0 0 1) + (0 0 0 0 1 1) + (0 0 0 1 1 1) + (0 0 1 1 1 1) + (0 1 1 1 1 1)))) + +(defun centaur-tabs-separator-memoize (func) + "Memoize FUNC. +If argument is a symbol then install the memoized function over +the original function. Use frame-local memoization." + (cl-typecase func + (symbol (fset func (centaur-tabs-separator-memoize-wrap-frame-local (symbol-function func))) func) + (function (centaur-tabs-separator-memoize-wrap-frame-local func)))) + +(defun centaur-tabs-separator-memoize-wrap-frame-local (func) + "Return the memoized version of FUNC. +The memoization cache is frame-local." + (let ((funcid (cl-gensym))) + `(lambda (&rest args) + ,(concat (documentation func) (format "\n(memoized function %s)" funcid)) + (let* ((cache (centaur-tabs-separator-create-or-get-cache)) + (key (cons ',funcid args)) + (val (gethash key cache))) + (if val + val + (puthash key (apply ,func args) cache)))))) + +(defun centaur-tabs-separator-create-or-get-cache () + "Return a frame-local hash table that acts as a memoization cache. +The cache is for the powerline. +Create one if the frame doesn't have one yet." + (let ((table (frame-parameter nil 'powerline-cache))) + (if (hash-table-p table) table (centaur-tabs-separator-reset-cache)))) + +(defun centaur-tabs-separator-reset-cache () + "Reset and return the frame-local hash table used for a memoization cache." + (let ((table (make-hash-table :test 'equal))) + ;; Store it as a frame-local variable + (modify-frame-parameters nil `((powerline-cache . ,table))) + table)) + +(centaur-tabs-separator-memoize (centaur-tabs-separator-alternate 'left)) +(centaur-tabs-separator-memoize (centaur-tabs-separator-alternate 'right)) +(centaur-tabs-separator-memoize (centaur-tabs-separator-bar 'left)) +(centaur-tabs-separator-memoize (centaur-tabs-separator-bar 'right)) +(centaur-tabs-separator-memoize (centaur-tabs-separator-box 'left)) +(centaur-tabs-separator-memoize (centaur-tabs-separator-box 'right)) +(centaur-tabs-separator-memoize (centaur-tabs-separator-chamfer 'left)) +(centaur-tabs-separator-memoize (centaur-tabs-separator-chamfer 'right)) +(centaur-tabs-separator-memoize (centaur-tabs-separator-rounded 'left)) +(centaur-tabs-separator-memoize (centaur-tabs-separator-rounded 'right)) +(centaur-tabs-separator-memoize (centaur-tabs-separator-slant 'left)) +(centaur-tabs-separator-memoize (centaur-tabs-separator-slant 'right)) +(centaur-tabs-separator-memoize (centaur-tabs-separator-wave 'left)) +(centaur-tabs-separator-memoize (centaur-tabs-separator-wave 'right)) +(centaur-tabs-separator-memoize (centaur-tabs-separator-zigzag 'left)) +(centaur-tabs-separator-memoize (centaur-tabs-separator-zigzag 'right)) + +(defun centaur-tabs-select-separator-style (tab-style) + "Set the separator style to TAB-STYLE." + (setq centaur-tabs-style-left (funcall (intern (format "powerline-%s-right" tab-style)) 'centaur-tabs-default nil centaur-tabs-height)) + (setq centaur-tabs-style-right (funcall (intern (format "powerline-%s-left" tab-style)) nil 'centaur-tabs-default centaur-tabs-height))) + +(provide 'centaur-tabs-elements) + +;;; centaur-tabs-elements.el ends here diff --git a/code/elpa/centaur-tabs-20230109.457/centaur-tabs-functions.el b/code/elpa/centaur-tabs-20230109.457/centaur-tabs-functions.el new file mode 100644 index 0000000..b220410 --- /dev/null +++ b/code/elpa/centaur-tabs-20230109.457/centaur-tabs-functions.el @@ -0,0 +1,1425 @@ +;;; centaur-tabs-functions.el --- centaur-tabs logic components -*- lexical-binding: t; -*- + +;; Copyright (C) 2019-2020 Emmanuel Bustos + +;; This file is not part of GNU Emacs. + +;; +;; This program is free software; you can redistribute it and/or +;; modify it under the terms of the GNU General Public License as +;; published by the Free Software Foundation; either version 2, or +;; (at your option) any later version. +;; +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +;; General Public License for more details. +;; +;; You should have received a copy of the GNU General Public License +;; along with this program; see the file COPYING. If not, write to +;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth +;; Floor, Boston, MA 02110-1301, USA. +;; +;;; Commentary: +;; This file contains functions that control the logic of centaur-tabs + +;;; Code: +;;; Require +(require 'cl-lib) +(require 'seq) +(require 'centaur-tabs-elements) + +;; Compiler pacifier +(declare-function ivy-read "ext:ivy.el" t t) +(declare-function helm-build-sync-source "ext:helm-source.el" t t) +(declare-function all-the-icons-match? "ext:all-the-icons.el" t t) +(declare-function all-the-icons-auto-mode-match? "ext:all-the-icons.el" t t) +(declare-function all-the-icons-icon-for-file "ext:all-the-icons.el" t t) +(declare-function all-the-icons-icon-for-mode "ext:all-the-icons.el" t t) +(declare-function projectile-project-root "ext:projectile.el" t t) +(declare-function projectile-project-name "ext:projectile.el" t t) +(defvar helm-source-centaur-tabs-group) + +;;; Customs +;; +(defcustom centaur-tabs-cycle-scope nil + "*Specify the scope of cyclic navigation through tabs. +The following scopes are possible: + +- `tabs' + Navigate through visible tabs only. +- `groups' + Navigate through tab groups only. +- default + Navigate through visible tabs, then through tab groups." + :group 'centaur-tabs + :type '(choice :tag "Cycle through..." + (const :tag "Visible Tabs Only" tabs) + (const :tag "Tab Groups Only" groups) + (const :tag "Visible Tabs then Tab Groups" nil))) + +(defcustom centaur-tabs-auto-scroll-flag t + "*Non-nil means to automatically scroll the tab bar. +That is, when a tab is selected outside of the tab bar visible area, +the tab bar is scrolled horizontally so the selected tab becomes +visible." + :group 'centaur-tabs + :type 'boolean) + +(defcustom centaur-tabs-common-group-name "Common" + "If the current buffer does not belong to any project the group name uses the name of this variable." + :group 'centaur-tabs + :type 'string) + +(defcustom centaur-tabs-label-fixed-length 0 + "Fixed length of label. Set to 0 if dynamic." + :group 'centaur-tabs + :type 'int) + +(defcustom centaur-tabs-hide-tabs-hooks + '(magit-status-mode-hook + magit-popup-mode-hook + reb-mode-hook + completion-list-mode-hook) + "Set hooks for buffers in which it isn't desired to have tabs." + :type '(repeat symbol) + :group 'centaur-tabs) + +(defcustom centaur-tabs-excluded-prefixes + '("*epc" + "*helm" + "*Helm" + " *which" + "*Compile-Log*" + "*lsp" + "*LSP" + "*company" + "*Flycheck" + "*Ediff" + "*ediff" + "*tramp" + " *Mini" + "*help" + "*straight" + " *temp" + "*Help") + "List of prefixes that indicates which buffers should not be included as tabs. +Buffers that have names that start with any of these strings will be ignored." + :type '(repeat string) + :group 'centaur-tabs) + +(defvar centaur-tabs-hide-tab-function 'centaur-tabs-hide-tab + "Function to hide tabs. +This function filters tabs. The tab will hide if this function returns t.") + +(defvar centaur-tabs-current-tabset-function nil + "Function called with no argument to obtain the current tab set. +This is the tab set displayed on the tab bar.") + +(defvar centaur-tabs-tab-label-function nil + "Function that obtains a tab label displayed on the tab bar. +The function is passed a tab and should return a string.") + +(defvar centaur-tabs-select-tab-function nil + "Function that selects a tab. +The function is passed a tab, and makes it the +selected tab.") + +(defvar centaur-tabs-buffer-list-function 'centaur-tabs-buffer-list + "Function that returns the list of buffers to show in the tab line. +That function is called with no arguments and must return a list of +buffers.") + +(defvar centaur-tabs-buffer-groups-function 'centaur-tabs-buffer-groups + "Function that gives the group names the current buffer belongs to. +It must return a list of group names, or nil if the buffer has no +group. Notice that it is better that a buffer belongs to one group.") + +(defvar centaur-tabs-adjust-buffer-order-function 'centaur-tabs-adjust-buffer-order + "Function to adjust buffer order after switch tab. +Default is `centaur-tabs-adjust-buffer-order', you can write your own rule.") + +(defcustom centaur-tabs-adjust-buffer-order nil + "Set automatic buffer ordering for buffer changing commands. +The ordering is appliet for non click or tab motion commands. +There are four options: +1 - nil: No ordering applied +2 - t: Move the currently selected tab to the side (right or left) of the last +visited tab. +3 - left: Move the currently selected tab to left of the last visited tab. +4 - right: Move the currently selected tab to right of the last visited tab." + :group 'centaur-tabs + :type '(choice :tag "Automatic buffer reordering..." + (const :tag "Do not adjust buffer order." nil) + (const :tag "When the currently selected tab(A) is at the right of the last visited +tab(B), move A to the right of B. When the currently selected tab(A) is at the left of the last visited +tab(B), move A to the left of B" t) + (const :tag "Move the currently selected tab to the left of the the last visited tab." left) + (const :tag "Move the currently selected tab to the right of the the last visited tab." right))) + +(defcustom centaur-tabs-enable-key-bindings nil + "Enable a selection of default key bindings for centaur-tabs." + :group 'centaur-tabs + :type 'boolean) + +(defun centaur-tabs-headline-match () + "Make headline use centaur-tabs-default-face." + (set-face-attribute centaur-tabs-display-line nil :background (face-background 'centaur-tabs-unselected nil 'default) + :box nil + :overline nil + :underline nil)) + +;; Change the font and height for all tab faces +(defun centaur-tabs-change-fonts (family height) + "Change the fonts of all the tabs. +FAMILY is the font family and HEIGHT is the font height." + (dolist (centaur-face '(centaur-tabs-selected + centaur-tabs-selected-modified + centaur-tabs-unselected + centaur-tabs-unselected-modified)) + (set-face-attribute centaur-face nil :family family :height height))) + +;;; Tabs Redisplay function +;; +(eval-and-compile + (defalias 'centaur-tabs-display-update + (if (fboundp 'force-window-update) + #'(lambda () (force-window-update (selected-window))) + 'force-mode-line-update))) + +;;; Name truncation +;; +;; Copied from s.el +(defun centaur-tabs-truncate-string (len s &optional ellipsis) + "If S is longer than LEN, cut it down and add ELLIPSIS to the end. + +The resulting string, including ellipsis, will be LEN characters +long. + +When not specified, ELLIPSIS defaults to ‘...’." + (declare (pure t) (side-effect-free t)) + (unless ellipsis + (setq ellipsis (if (char-displayable-p ?…) "…" "..."))) + (if (> (length s) len) + (format "%s%s" (substring s 0 (- len (length ellipsis))) ellipsis) + (concat s (make-string (- len (length s)) ? )))) + +;;; Keymaps +;; +(defvar centaur-tabs-prefix-key ["C-c t"] + "The common prefix key used in Centaur-Tabs mode.") + +(defvar centaur-tabs-prefix-map + (let ((km (make-sparse-keymap))) + (define-key km (kbd "") 'centaur-tabs-backward) + (define-key km (kbd "") 'centaur-tabs-forward) + (define-key km (kbd "") 'centaur-tabs-backward-group) + (define-key km (kbd "") 'centaur-tabs-forward-group) + (define-key km (kbd "f10") 'centaur-tabs-local-mode) + (define-key km (kbd "C-5") 'centaur-tabs-extract-window-to-new-frame) + (define-key km (kbd "a") 'centaur-tabs-ace-jump) + (define-key km (kbd "s") 'centaur-tabs-counsel-switch-group) + (define-key km (kbd "p") 'centaur-tabs-group-by-projectile-project) + (define-key km (kbd "g") 'centaur-tabs-group-buffer-groups) + (define-key km (kbd "k") 'centaur-tabs-kill-all-buffers-in-current-group) + (define-key km (kbd "o") 'centaur-tabs-kill-other-buffers-in-current-group) + (define-key km (kbd "d") 'centaur-tabs-open-directory-in-external-application) + km) + "The key bindings provided in Centaur-Tabs mode.") + +(defvar centaur-tabs-mode-map + (let ((map (make-sparse-keymap))) + ;; Optional keybord bindings + (when centaur-tabs-enable-key-bindings + (define-key map centaur-tabs-prefix-key centaur-tabs-prefix-map)) + ;;; Use mouse wheel to switch between buffers of same group + (define-key map (vector centaur-tabs-display-line 'mouse-5 ) 'centaur-tabs-forward ) + (define-key map (vector centaur-tabs-display-line 'mouse-4 ) 'centaur-tabs-backward) + (define-key map (vector centaur-tabs-display-line 'wheel-down) 'centaur-tabs-forward ) + (define-key map (vector centaur-tabs-display-line 'wheel-up ) 'centaur-tabs-backward) + + ;;; Use right click to show the rest of groups + (define-key map (vector centaur-tabs-display-line 'mouse-3) 'centaur-tabs--tab-menu ) + + ;;; Use double click to maximize window + (define-key map (vector centaur-tabs-display-line 'double-mouse-1) 'delete-other-windows) + + map) + "Keymap to use in Centaur-Tabs mode.") + +(defvar centaur-tabs-close-map + (let ((map (make-sparse-keymap))) + (define-key map (vector centaur-tabs-display-line 'mouse-1) 'centaur-tabs-do-close) + (define-key map (vector centaur-tabs-display-line 'mouse-2) 'centaur-tabs-do-close) + map) + "Keymap used for setting mouse events for close button.") + +(defvar centaur-tabs-backward-tab-map + (let ((map (make-sparse-keymap))) + (define-key map (vector centaur-tabs-display-line 'mouse-1) 'centaur-tabs-backward--button) + (define-key map (vector centaur-tabs-display-line 'mouse-3) 'centaur-tabs--groups-menu) + (define-key map (vector centaur-tabs-display-line 'C-mouse-1) 'centaur-tabs-move-current-tab-to-left--button) + map) + "Keymap used for setting mouse events for backward tab button.") + +(defvar centaur-tabs-forward-tab-map + (let ((map (make-sparse-keymap))) + (define-key map (vector centaur-tabs-display-line 'mouse-1) 'centaur-tabs-forward--button) + (define-key map (vector centaur-tabs-display-line 'mouse-3) 'centaur-tabs--groups-menu) + (define-key map (vector centaur-tabs-display-line 'C-mouse-1) 'centaur-tabs-move-current-tab-to-right--button) + map) + "Keymap used for setting mouse events for forward tab button.") + +(defvar centaur-tabs-down-tab-map + (let ((map (make-sparse-keymap))) + (define-key map (vector centaur-tabs-display-line 'mouse-1) 'centaur-tabs--groups-menu) + (define-key map (vector centaur-tabs-display-line 'mouse-3) 'centaur-tabs--groups-menu) + map) + "Keymap used for setting mouse events for down tab button.") + +(defvar centaur-tabs-default-map + (let ((map (make-sparse-keymap))) + (define-key map (vector centaur-tabs-display-line 'mouse-1) 'centaur-tabs-do-select) + (define-key map (vector centaur-tabs-display-line 'mouse-2) 'centaur-tabs-do-close) + map) + "Keymap used for setting mouse events for a tab.") + +(defvar centaur-tabs-new-tab-map + (let ((map (make-sparse-keymap))) + (define-key map (vector centaur-tabs-display-line 'mouse-1) 'centaur-tabs-new-tab--button) + map) + "Keymap used for setting mouse events for new tab button.") + +;;; Events and event functions +;; +(defun centaur-tabs-buffer-close-tab (tab) + "Function for closing TAB." + (let ((buffer (centaur-tabs-tab-value tab))) + (with-current-buffer buffer + (kill-buffer buffer)) + (centaur-tabs-display-update))) + +(defun centaur-tabs-get-tab-from-event (event) + "Given a mouse EVENT, extract the tab at the mouse point." + (let ((pos (posn-string (event-start event)))) + (get-text-property (cdr pos) 'centaur-tabs-tab (car pos)))) + +(defun centaur-tabs-do-select (event) + "Given a mouse EVENT, select the tab at the mouse point." + (interactive "e") + (select-window (posn-window (event-start event))) + (centaur-tabs-buffer-select-tab `,(centaur-tabs-get-tab-from-event event))) + +(defun centaur-tabs-do-close (event) + "Given a mouse EVENT, close the tab at the mouse point." + (interactive "e") + (let ((window (posn-window (event-start event)))) + (with-selected-window window + (select-window window) + (let ((foreground-buffer-name (buffer-name))) + (centaur-tabs-buffer-select-tab `,(centaur-tabs-get-tab-from-event event)) + + (let* ((buffer (window-buffer window)) + (target-buffer-name (buffer-name)) + (same-target-check (string-equal foreground-buffer-name target-buffer-name)) + (window-num (- (length (get-buffer-window-list buffer)) + (if same-target-check 0 1)))) + (if (> window-num 1) + (delete-window window) + (centaur-tabs-buffer-close-tab `,(centaur-tabs-get-tab-from-event event)))))))) + +(defun centaur-tabs-backward--button (event) + "Same as centaur-tabs-backward, but changing window to EVENT source." + (interactive "e") + (select-window (posn-window (event-start event))) + (centaur-tabs-backward)) + +(defun centaur-tabs-forward--button (event) + "Same as centaur-tabs-forward, but changing window to EVENT source." + (interactive "e") + (select-window (posn-window (event-start event))) + (centaur-tabs-forward)) + +(defun centaur-tabs-new-tab--button (event) + "Same as centaur-tabs--create-new-tab, but changing window to EVENT source." + (interactive "e") + (select-window (posn-window (event-start event))) + (centaur-tabs--create-new-tab)) + +(defun centaur-tabs-move-current-tab-to-left--button (evt) + "Same as centaur-tabs-move-current-tab-to-left, but ensuring the tab will remain visible. The active window will the the EVT source." + (interactive "e") + (centaur-tabs-move-current-tab-to-left) + (centaur-tabs--button-ensure-selected-tab-is-visible evt)) + + +(defun centaur-tabs-move-current-tab-to-right--button (evt) + "Same as centaur-tabs-move-current-tab-to-right, but ensuring the tab will remain visible. The active window will the the EVT source." + (interactive "e") + (centaur-tabs-move-current-tab-to-right) + (centaur-tabs--button-ensure-selected-tab-is-visible evt)) + +(defun centaur-tabs--button-ensure-selected-tab-is-visible (evt) + "This is a nasty trick to make the current tab visible, since centaur-tabs--track-selected or centaur-tabs-auto-scroll-flag seems not to work. EVT is used to change the active window." + ;;; This works if the tab has not reached the last position + (centaur-tabs-forward--button evt) + (centaur-tabs-backward--button evt) + ;;; Just in case the tab has the tab reached the last position + (centaur-tabs-backward--button evt) + (centaur-tabs-forward--button evt)) + + +;;; Tab and tab sets +;; +(defsubst centaur-tabs-make-tab (object tabset) + "Return a new tab with value OBJECT. +TABSET is the tab set the tab belongs to." + (cons object tabset)) + +(defsubst centaur-tabs-tab-value (tab) + "Return the value of tab TAB." + (car tab)) + +(defsubst centaur-tabs-tab-tabset (tab) + "Return the tab set TAB belongs to." + (cdr tab)) + +(defvar centaur-tabs-tabsets nil + "The tab sets store.") + +(defvar centaur-tabs-tabsets-tabset nil + "The special tab set of existing tab sets.") + +(defvar centaur-tabs-current-tabset nil + "The tab set currently displayed on the tab bar.") +(make-variable-buffer-local 'centaur-tabs-current-tabset) + +(defvar centaur-tabs-init-hook nil + "Hook run after tab bar data has been initialized. +You should use this hook to initialize dependent data.") + +(defsubst centaur-tabs-init-tabsets-store () + "Initialize the tab set store." + (setq centaur-tabs-tabsets (make-vector 31 0) + centaur-tabs-tabsets-tabset (make-symbol "centaur-tabs-tabsets-tabset")) + (put centaur-tabs-tabsets-tabset 'start 0) + (run-hooks 'centaur-tabs-init-hook)) + +(defvar centaur-tabs-quit-hook nil + "Hook run after tab bar data has been freed. +You should use this hook to reset dependent data.") + +(defsubst centaur-tabs-free-tabsets-store () + "Free the tab set store." + (setq centaur-tabs-tabsets nil + centaur-tabs-tabsets-tabset nil) + (run-hooks 'centaur-tabs-quit-hook)) + +;; Define an "hygienic" function free of side effect between its local +;; variables and those of the callee. +(eval-and-compile + (defalias 'centaur-tabs-map-tabsets + (let ((function (make-symbol "function")) + (result (make-symbol "result")) + (tabset (make-symbol "tabset"))) + `(lambda (,function) + "Apply FUNCTION to each tab set, and make a list of the results. +The result is a list just as long as the number of existing tab sets." + (let (,result) + (mapatoms + #'(lambda (,tabset) + (push (funcall ,function ,tabset) ,result)) + centaur-tabs-tabsets) + ,result))))) + +(defun centaur-tabs-make-tabset (name &rest objects) + "Make a new tab set whose name is the string NAME. +It is initialized with tabs build from the list of OBJECTS." + (let* ((tabset (intern name centaur-tabs-tabsets)) + (tabs (cl-mapcar #'(lambda (object) + (centaur-tabs-make-tab object tabset)) + objects))) + (set tabset tabs) + (centaur-tabs-put-cache tabset 'select (car tabs)) + (put tabset 'start 0) + tabset)) + +(defsubst centaur-tabs-get-tabset (name) + "Return the tab set whose name is the string NAME. +Return nil if not found." + (intern-soft name centaur-tabs-tabsets)) + +(defsubst centaur-tabs-delete-tabset (tabset) + "Delete the tab set TABSET. +That is, remove it from the tab sets store." + (unintern tabset centaur-tabs-tabsets)) + +(defsubst centaur-tabs-tabs (tabset) + "Return the list of tabs in TABSET." + (symbol-value tabset)) + +(defsubst centaur-tabs-tab-values (tabset) + "Return the list of tab values in TABSET." + (cl-mapcar 'centaur-tabs-tab-value (centaur-tabs-tabs tabset))) + +(defun centaur-tabs-get-cache (cache key) + "Return the per-frame cached value of KEY in CACHE." + (let + ((cached-hash (frame-parameter nil cache))) + (if (hash-table-p cached-hash) + (gethash key cached-hash nil)))) + +(defun centaur-tabs-put-cache (cache key value) + "Set the per-frame cached value of KEY in CACHE to VALUE." + (let* + ((cached-hash (frame-parameter nil cache)) + (hash (if (hash-table-p cached-hash) cached-hash (make-hash-table)))) + (puthash key value hash) + (set-frame-parameter nil cache hash)) + value) + +(defsubst centaur-tabs-get-tab (object tabset) + "Search for a tab with value OBJECT in TABSET. +Return the tab found, or nil if not found." + (assoc object (centaur-tabs-tabs tabset))) + +(defsubst centaur-tabs-member (tab tabset) + "Return non-nil if TAB is in TABSET." + (or (eq (centaur-tabs-tab-tabset tab) tabset) + (memq tab (centaur-tabs-tabs tabset)))) + +(defsubst centaur-tabs-template (tabset) + "Return the cached visual representation of TABSET. +That is, a `centaur-tabs-display-line-format' template, or nil if the cache is +empty." + (centaur-tabs-get-cache tabset 'template)) + +(defsubst centaur-tabs-set-template (tabset template) + "Set the cached visual representation of TABSET to TEMPLATE. +TEMPLATE must be a valid `centaur-tabs-display-line-format' template, or nil to +cleanup the cache." + (centaur-tabs-put-cache tabset 'template template)) + +(defsubst centaur-tabs-selected-tab (tabset) + "Return the tab selected in TABSET." + (centaur-tabs-get-cache tabset 'select)) + +(defsubst centaur-tabs-selected-value (tabset) + "Return the value of the tab selected in TABSET." + (centaur-tabs-tab-value (centaur-tabs-selected-tab tabset))) + +(defsubst centaur-tabs-selected-p (tab tabset) + "Return non-nil if TAB is the selected tab in TABSET." + (eq tab (centaur-tabs-selected-tab tabset))) + +(defvar centaur-tabs--track-selected nil) + +(defsubst centaur-tabs-select-tab (tab tabset) + "Make TAB the selected tab in TABSET. +Does nothing if TAB is not found in TABSET. +Return TAB if selected, nil if not." + (when (centaur-tabs-member tab tabset) + (unless (centaur-tabs-selected-p tab tabset) + (centaur-tabs-set-template tabset nil) + (setq centaur-tabs--track-selected centaur-tabs-auto-scroll-flag)) + (centaur-tabs-put-cache tabset 'select tab))) + +(defsubst centaur-tabs-select-tab-value (object tabset) + "Make the tab with value OBJECT, the selected tab in TABSET. +Does nothing if a tab with value OBJECT is not found in TABSET. +Return the tab selected, or nil if nothing was selected." + (centaur-tabs-select-tab (centaur-tabs-get-tab object tabset) tabset)) + +(defsubst centaur-tabs-start (tabset) + "Return the index of the first visible tab in TABSET." + (get tabset 'start)) + +(defsubst centaur-tabs-view (tabset) + "Return the list of visible tabs in TABSET. +That is, the sub-list of tabs starting at the first visible one." + (nthcdr (centaur-tabs-start tabset) (centaur-tabs-tabs tabset))) + +(defun centaur-tabs-add-tab (tabset object) + "Check if OBJECT tab is already open in TABSET. +Otherwise insert it." + (let ((tabs (centaur-tabs-tabs tabset))) + (if (centaur-tabs-get-tab object tabset) + tabs + (let* ((tab (centaur-tabs-make-tab object tabset)) + (selected (centaur-tabs-selected-tab tabset)) + (selected-index (cl-position (car selected) (cl-mapcar 'car tabs)))) + (centaur-tabs-set-template tabset nil) + (set tabset (centaur-tabs-insert-at tabs selected-index tab)))))) + +(defun centaur-tabs-insert-at (list index insert-element) + "Insert INSERT-ELEMENT in LIST at index INDEX." + (let ((counter 0) + result) + (dolist (element list) + (if (equal counter index) + (setq result (append result (list element insert-element))) + (setq result (append result (list element)))) + (setq counter (+ 1 counter))) + result)) + +(defun centaur-tabs-delete-tab (tab) + "Remove TAB from its tab set." + (let* ((tabset (centaur-tabs-tab-tabset tab)) + (tabs (centaur-tabs-tabs tabset)) + (sel (eq tab (centaur-tabs-selected-tab tabset))) + (next (and sel (cdr (memq tab tabs))))) + (centaur-tabs-set-template tabset nil) + (setq tabs (delq tab tabs)) + ;; When the selected tab is deleted, select the next one, if + ;; available, or the last one otherwise. + (and sel (centaur-tabs-select-tab (car (or next (last tabs))) tabset)) + (set tabset tabs))) + +(defun centaur-tabs-scroll (tabset count) + "Scroll the visible tabs in TABSET of COUNT units. +If COUNT is positive move the view on right. If COUNT is negative, +move the view on left." + (let ((start (min (max 0 (+ (centaur-tabs-start tabset) count)) + (1- (length (centaur-tabs-tabs tabset)))))) + (when (/= start (centaur-tabs-start tabset)) + (centaur-tabs-set-template tabset nil) + (put tabset 'start start)))) + +(defun centaur-tabs-tab-next (tabset tab &optional before) + "Search in TABSET for the tab after TAB. +If optional argument BEFORE is non-nil, search for the tab before +TAB. Return the tab found, or nil otherwise." + (let* (last (tabs (centaur-tabs-tabs tabset))) + (while (and tabs (not (eq tab (car tabs)))) + (setq last (car tabs) + tabs (cdr tabs))) + (and tabs (if before last (nth 1 tabs))))) + +(defun centaur-tabs-current-tabset (&optional update) + "Return the tab set currently displayed on the tab bar. +If optional argument UPDATE is non-nil, call the user defined function +`centaur-tabs-current-tabset-function' to obtain it. Otherwise return the +current cached copy." + (and update centaur-tabs-current-tabset-function + (setq centaur-tabs-current-tabset + (funcall centaur-tabs-current-tabset-function))) + centaur-tabs-current-tabset) + +(defun centaur-tabs-get-tabsets-tabset () + "Return the tab set of selected tabs in existing tabsets." + (set centaur-tabs-tabsets-tabset (centaur-tabs-map-tabsets 'centaur-tabs-selected-tab)) + (centaur-tabs-scroll centaur-tabs-tabsets-tabset 0) + (centaur-tabs-set-template centaur-tabs-tabsets-tabset nil) + centaur-tabs-tabsets-tabset) + +;; Functions for modification hooks and advices +(defun centaur-tabs-on-saving-buffer () + "Function to be run after the buffer is saved." + (centaur-tabs-set-template centaur-tabs-current-tabset nil) + (centaur-tabs-display-update)) +(defun centaur-tabs-on-modifying-buffer () + "Function to be run after the buffer is first changed." + (set-buffer-modified-p (buffer-modified-p)) + (centaur-tabs-set-template centaur-tabs-current-tabset nil) + (centaur-tabs-display-update)) +(defun centaur-tabs-after-modifying-buffer (&rest _) + "Function to be run after the buffer is changed. +BEGIN, END and LENGTH are just standard arguments for after-changes-function +hooked functions" + (set-buffer-modified-p (buffer-modified-p)) + (centaur-tabs-set-template centaur-tabs-current-tabset nil) + (centaur-tabs-display-update)) + +;;; Tabs display +;; +(defsubst centaur-tabs-line-tab (tab) + "Return the display representation of tab TAB. +That is, a propertized string used as an `centaur-tabs-display-line-format' +template element. +Call `centaur-tabs-tab-label-function' to obtain a label for TAB." + (let* ((buf (centaur-tabs-tab-value tab)) + (buf-file-name (buffer-file-name buf)) + (selected-p (centaur-tabs-selected-p tab (centaur-tabs-current-tabset))) + (not-read-only-p (with-current-buffer buf (not buffer-read-only))) + (modified-p (and not-read-only-p (buffer-modified-p buf))) + (use-mod-mark-p (and centaur-tabs-set-modified-marker modified-p)) + (mod-mark-face (if selected-p + 'centaur-tabs-modified-marker-selected + 'centaur-tabs-modified-marker-unselected)) + (face (if selected-p + (if modified-p + 'centaur-tabs-selected-modified + 'centaur-tabs-selected) + (if modified-p + 'centaur-tabs-unselected-modified + 'centaur-tabs-unselected))) + (bar (if (and selected-p (eq (if (display-graphic-p) centaur-tabs-set-bar) 'left)) + (propertize + centaur-tabs-active-bar + 'centaur-tabs-tab tab + 'pointer centaur-tabs-mouse-pointer + 'local-map centaur-tabs-default-map) + "")) + (icon (if (and centaur-tabs-set-icons + (not centaur-tabs--buffer-show-groups)) + (propertize + (centaur-tabs-icon tab face selected-p) + 'centaur-tabs-tab tab + 'pointer centaur-tabs-mouse-pointer + 'help-echo (with-current-buffer buf (format-mode-line mode-name)) + 'local-map centaur-tabs-default-map) + ""))) + (when (or (not centaur-tabs-style-left) + (not centaur-tabs-style-right)) + (centaur-tabs-select-separator-style centaur-tabs-style)) + (concat + (centaur-tabs-separator-render centaur-tabs-style-left face) + bar + + ;; left margin + (if centaur-tabs-left-edge-margin + (propertize + centaur-tabs-left-edge-margin + 'face face + 'centaur-tabs-tab tab + 'pointer centaur-tabs-mouse-pointer + 'local-map centaur-tabs-default-map)) + + ;; left close button + (if centaur-tabs-set-left-close-button + (propertize + centaur-tabs-close-button + 'face (if selected-p + 'centaur-tabs-close-selected + 'centaur-tabs-close-unselected) + 'pointer centaur-tabs-mouse-pointer + 'help-echo "Close buffer" + 'centaur-tabs-tab tab + 'mouse-face 'centaur-tabs-close-mouse-face + 'local-map centaur-tabs-close-map)) + + ;; icon + (if (= (length icon) 0) "" + (concat + (propertize + " " + 'face face + 'centaur-tabs-tab tab + 'pointer centaur-tabs-mouse-pointer + 'local-map centaur-tabs-default-map) + icon)) + + ;; tab name + (propertize + (concat + (if centaur-tabs-tab-label-function + (funcall centaur-tabs-tab-label-function tab) + (buffer-name buf)) + " ") + 'centaur-tabs-tab tab + 'face face + 'mouse-face 'centaur-tabs-name-mouse-face + 'pointer centaur-tabs-mouse-pointer + 'help-echo buf-file-name + 'local-map centaur-tabs-default-map) + + ;; tab identifier + (when centaur-tabs-show-jump-identifier + (when (or (eq centaur-tabs-show-jump-identifier 'always) centaur-tabs-ace-jump-active) + (propertize + (format "%c" (nth (cl-position tab (centaur-tabs-view (centaur-tabs-current-tabset t))) centaur-tabs-ace-jump-keys)) + 'centaur-tabs-tab tab + 'face (if selected-p + 'centaur-tabs-jump-identifier-selected + 'centaur-tabs-jump-identifier-unselected) + 'pointer centaur-tabs-mouse-pointer + 'help-echo buf-file-name + 'local-map centaur-tabs-default-map))) + + ;; close button and/or modified marker + (unless centaur-tabs-ace-jump-active + (if centaur-tabs-set-close-button + (propertize + (if use-mod-mark-p + centaur-tabs-modified-marker + centaur-tabs-close-button) + 'face (if use-mod-mark-p + mod-mark-face + (if selected-p + 'centaur-tabs-close-selected + 'centaur-tabs-close-unselected)) + 'pointer centaur-tabs-mouse-pointer + 'help-echo "Close buffer" + 'centaur-tabs-tab tab + 'mouse-face 'centaur-tabs-close-mouse-face + 'local-map centaur-tabs-close-map) + (if (and centaur-tabs-set-modified-marker modified-p) + (propertize + centaur-tabs-modified-marker + 'face mod-mark-face + 'pointer centaur-tabs-mouse-pointer + 'centaur-tabs-tab tab + 'help-echo buf-file-name + 'local-map centaur-tabs-default-map) + "" ))) + + ;; right margin + (if centaur-tabs-right-edge-margin + (propertize + centaur-tabs-right-edge-margin + 'face face + 'centaur-tabs-tab tab + 'pointer centaur-tabs-mouse-pointer + 'local-map centaur-tabs-default-map)) + + (centaur-tabs-separator-render centaur-tabs-style-right face)))) + +(defsubst centaur-tabs-button-tab (button) + "Return the display representation of button BUTTON. +That is, a propertized string used as an `centaur-tabs-display-line-format' +template element." + (let* ((face 'centaur-tabs-unselected)) + (concat + (propertize + button + 'face face + 'mouse-face 'highlight)))) + +(defun centaur-tabs-line-format (tabset) + "Return the `centaur-tabs-display-line-format' value to display TABSET." + (let* ((sel (centaur-tabs-selected-tab tabset)) + (tabs (centaur-tabs-view tabset)) + (padcolor centaur-tabs-background-color) + (all-tabs (centaur-tabs-tabs tabset)) + (total-tabs (length all-tabs)) + (sel-index (+ (cl-position (car sel) (cl-mapcar 'car all-tabs)) 1)) + atsel elts) + ;; Track the selected tab to ensure it is always visible. + (when centaur-tabs--track-selected + (while (not (memq sel tabs)) + (centaur-tabs-scroll tabset -1) + (setq tabs (centaur-tabs-view tabset))) + (while (and tabs (not atsel)) + (setq elts (cons (centaur-tabs-line-tab (car tabs)) elts) + atsel (eq (car tabs) sel) + tabs (cdr tabs))) + (setq elts (nreverse elts)) + ;; At this point the selected tab is the last elt in ELTS. + ;; Scroll TABSET and ELTS until the selected tab becomes + ;; visible. + (let (buffer-list-update-hook) + (with-temp-buffer + (let ((truncate-partial-width-windows nil) + (inhibit-modification-hooks t) + deactivate-mark ;; Prevent deactivation of the mark! + start) + (setq truncate-lines nil + buffer-undo-list t) + (setq start (point)) + (while (and (cdr elts) ;; Always show the selected tab! + (progn + (delete-region start (point-max)) + (goto-char (point-max)) + (apply #'insert elts) + (goto-char (point-min)) + (> (vertical-motion 1) 0))) + (centaur-tabs-scroll tabset 1) + (setq elts (cdr elts)))))) + (setq elts (nreverse elts)) + (setq centaur-tabs--track-selected nil)) + ;; Format remaining tabs. + (while tabs + (setq elts (cons (centaur-tabs-line-tab (car tabs)) elts) + tabs (cdr tabs))) + ;; Cache and return the new tab bar. + (centaur-tabs-set-template + tabset + (list + (centaur-tabs-count sel-index total-tabs) + (centaur-tabs-line-format--buttons) + (nreverse elts) + (propertize "% " + 'face (list :background padcolor) + 'pointer 'arrow) + (centaur-tabs-line-format--new-button))) + )) + +(defun centaur-tabs-count (index count) + "Return a centaur-tabs-button-tab with the current tab INDEX and the total tabs COUNT." + (if centaur-tabs-show-count + (propertize (centaur-tabs-button-tab (format " [%d/%d] " index count)) + 'help-echo "Tabs count") + "")) + +(defun centaur-tabs-line-format--buttons () + "Return the buttons fragment of the header line." + (if (and centaur-tabs-show-navigation-buttons (display-graphic-p)) + (list + (propertize (centaur-tabs-button-tab centaur-tabs-down-tab-text) + 'local-map centaur-tabs-down-tab-map + 'help-echo "Change tab group") + (propertize (centaur-tabs-button-tab centaur-tabs-backward-tab-text) + 'local-map centaur-tabs-backward-tab-map + 'help-echo "Previous tab") + (propertize (centaur-tabs-button-tab centaur-tabs-forward-tab-text) + 'local-map centaur-tabs-forward-tab-map + 'help-echo "Next tab")) + "")) + +(defun centaur-tabs-line-format--new-button () + "Return the new-tab button fragment at the right end of the header line." + (if centaur-tabs-show-new-tab-button + (concat + (propertize (centaur-tabs-button-tab centaur-tabs-new-tab-text) + 'local-map centaur-tabs-new-tab-map + 'help-echo "Create new tab") + ""))) + +(defun centaur-tabs-line () + "Return the header line templates that represent the tab bar. +Inhibit display of the tab bar in current window where +`centaur-tabs-hide-tab-function' return t." + (cond + ((centaur-tabs-hide-tab-cached (current-buffer)) + ;; Don't show the tab bar. + (set centaur-tabs-display-line-format nil)) + ((centaur-tabs-current-tabset t) + ;; When available, use a cached tab bar value, else recompute it. + (or (centaur-tabs-template centaur-tabs-current-tabset) + (centaur-tabs-line-format centaur-tabs-current-tabset))))) + +(defconst centaur-tabs-header-line-format '(:eval (centaur-tabs-line)) + "The tab bar header line format.") + +;;; Cyclic navigation through tabs +;; +(defun centaur-tabs-cycle (&optional backward) + "Cycle to the next available tab. +The scope of the cyclic navigation through tabs is specified by the +option `centaur-tabs-cycle-scope'. +If optional argument BACKWARD is non-nil, cycle to the previous tab +instead." + (let* ((tabset (centaur-tabs-current-tabset t)) + (ttabset (centaur-tabs-get-tabsets-tabset)) + ;; If navigation through groups is requested, and there is + ;; only one group, navigate through visible tabs. + (cycle (if (and (eq centaur-tabs-cycle-scope 'groups) + (not (cdr (centaur-tabs-tabs ttabset)))) + 'tabs + centaur-tabs-cycle-scope)) + selected tab) + (when tabset + (setq selected (centaur-tabs-selected-tab tabset)) + (cond + ;; Cycle through visible tabs only. + ((eq cycle 'tabs) + (setq tab (centaur-tabs-tab-next tabset selected backward)) + ;; When there is no tab after/before the selected one, cycle + ;; to the first/last visible tab. + (unless tab + (setq tabset (centaur-tabs-tabs tabset) + tab (car (if backward (last tabset) tabset)))) + ) + ;; Cycle through tab groups only. + ((eq cycle 'groups) + (setq tab (centaur-tabs-tab-next ttabset selected backward)) + ;; When there is no group after/before the selected one, cycle + ;; to the first/last available group. + (unless tab + (setq tabset (centaur-tabs-tabs ttabset) + tab (car (if backward (last tabset) tabset)))) + ) + (t + ;; Cycle through visible tabs then tab groups. + (setq tab (centaur-tabs-tab-next tabset selected backward)) + ;; When there is no visible tab after/before the selected one, + ;; cycle to the next/previous available group. + (unless tab + (setq tab (centaur-tabs-tab-next ttabset selected backward)) + ;; When there is no next/previous group, cycle to the + ;; first/last available group. + (unless tab + (setq tabset (centaur-tabs-tabs ttabset) + tab (car (if backward (last tabset) tabset)))) + ;; Select the first/last visible tab of the new group. + (setq tabset (centaur-tabs-tabs (centaur-tabs-tab-tabset tab)) + tab (car (if backward (last tabset) tabset)))) + )) + (centaur-tabs-buffer-select-tab tab)))) + +;;;###autoload +(defun centaur-tabs-backward () + "Select the previous available tab. +Depend on the setting of the option `centaur-tabs-cycle-scope'." + (interactive) + (if (centaur-tabs-current-tabset t) + (centaur-tabs-cycle t) + (previous-buffer))) + +;;;###autoload +(defun centaur-tabs-forward () + "Select the next available tab. +Depend on the setting of the option `centaur-tabs-cycle-scope'." + (interactive) + (if (centaur-tabs-current-tabset t) + (centaur-tabs-cycle) + (next-buffer))) + +;;;###autoload +(defun centaur-tabs-backward-group () + "Go to selected tab in the previous available group." + (interactive) + (let ((centaur-tabs-cycle-scope 'groups)) + (centaur-tabs-cycle t))) + +;;;###autoload +(defun centaur-tabs-forward-group () + "Go to selected tab in the next available group." + (interactive) + (let ((centaur-tabs-cycle-scope 'groups)) + (centaur-tabs-cycle))) + +;;;###autoload +(defun centaur-tabs-backward-tab () + "Select the previous visible tab." + (interactive) + (let ((centaur-tabs-cycle-scope 'tabs)) + (centaur-tabs-cycle t))) + +;;;###autoload +(defun centaur-tabs-forward-tab () + "Select the next visible tab." + (interactive) + (let ((centaur-tabs-cycle-scope 'tabs)) + (centaur-tabs-cycle))) + +;;; Buffer tabs +;; +(defgroup centaur-tabs-buffer nil + "Display buffers in the tab bar." + :group 'centaur-tabs) + +(defun centaur-tabs-filter-out (condp lst) + "Filter list LST with using CONDP as the filtering condition." + (delq nil + (cl-mapcar (lambda (x) (if (funcall condp x) nil x)) lst))) + +(defun centaur-tabs-buffer-list () + "Return the list of buffers to show in tabs. +Exclude buffers whose name starts with a space, when they are not +visiting a file. The current buffer is always included." + (centaur-tabs-filter-out + 'centaur-tabs-hide-tab-cached + (delq nil + (cl-mapcar #'(lambda (b) + (cond + ;; Always include the current buffer. + ((eq (current-buffer) b) b) + ((buffer-file-name b) b) + ((char-equal ?\ (aref (buffer-name b) 0)) nil) + ((buffer-live-p b) b))) + (buffer-list))))) + +(defun centaur-tabs-buffer-mode-derived-p (mode parents) + "Return non-nil if MODE derives from a mode in PARENTS." + (let (derived) + (while (and (not derived) mode) + (if (memq mode parents) + (setq derived t) + (setq mode (get mode 'derived-mode-parent)))) + derived)) + +;;; Group buffers in tab sets. +;; +(defvar centaur-tabs--buffers nil) + +(defun centaur-tabs-buffer-update-groups () + "Update tabsets from groups of existing buffers. +Return the the first group where the current buffer is." + (let ((bl (sort + (cl-mapcar + #'(lambda (b) + (with-current-buffer b + (list (current-buffer) + (buffer-name) + (if centaur-tabs-buffer-groups-function + (funcall centaur-tabs-buffer-groups-function) + '(centaur-tabs-common-group-name))))) + (and centaur-tabs-buffer-list-function + (funcall centaur-tabs-buffer-list-function))) + #'(lambda (e1 e2) + (string-lessp (nth 1 e1) (nth 1 e2)))))) + ;; If the cache has changed, update the tab sets. + (unless (equal bl centaur-tabs--buffers) + ;; Add new buffers, or update changed ones. + (dolist (e bl) + (dolist (g (nth 2 e)) + (let ((tabset (centaur-tabs-get-tabset g))) + (if tabset + (unless (equal e (assq (car e) centaur-tabs--buffers)) + ;; This is a new buffer, or a previously existing + ;; buffer that has been renamed, or moved to another + ;; group. Update the tab set, and the display. + (centaur-tabs-add-tab tabset (car e)) + (centaur-tabs-set-template tabset nil)) + (centaur-tabs-make-tabset g (car e)))))) + ;; Remove tabs for buffers not found in cache or moved to other + ;; groups, and remove empty tabsets. + (mapc 'centaur-tabs-delete-tabset + (centaur-tabs-map-tabsets + #'(lambda (tabset) + (dolist (tab (centaur-tabs-tabs tabset)) + (let ((e (assq (centaur-tabs-tab-value tab) bl))) + (or (and e (memq tabset + (cl-mapcar 'centaur-tabs-get-tabset + (nth 2 e)))) + (centaur-tabs-delete-tab tab)))) + ;; Return empty tab sets + (unless (centaur-tabs-tabs tabset) + tabset)))) + ;; The new cache becomes the current one. + (setq centaur-tabs--buffers bl))) + ;; Return the first group the current buffer belongs to. + (car (nth 2 (assq (current-buffer) centaur-tabs--buffers)))) + +;;; Tab bar callbacks +;; + +(defsubst centaur-tabs-buffer-show-groups (flag) + "Set display of tabs for groups of buffers to FLAG." + (setq centaur-tabs--buffer-show-groups flag)) + +(defun centaur-tabs-buffer-tabs () + "Return the buffers to display on the tab bar, in a tab set." + (let ((tabset (centaur-tabs-get-tabset (centaur-tabs-buffer-update-groups)))) + (centaur-tabs-select-tab-value (current-buffer) tabset) + (when centaur-tabs--buffer-show-groups + (setq tabset (centaur-tabs-get-tabsets-tabset)) + (centaur-tabs-select-tab-value (current-buffer) tabset)) + tabset)) + +(defun centaur-tabs-buffer-tab-label (tab) + "Return a label for TAB. +That is, a string used to represent it on the tab bar." + ;; Init tab style. + ;; Render tab. + (format " %s" + (let ((bufname (if centaur-tabs--buffer-show-groups + (centaur-tabs-tab-tabset tab) + (buffer-name (car tab))))) + (if (> centaur-tabs-label-fixed-length 0) + (centaur-tabs-truncate-string centaur-tabs-label-fixed-length bufname) + bufname)))) + +(defvar centaur-tabs-last-scroll-y 0 + "Holds the scroll y of window from the last run of post-command-hooks.") + +(defun centaur-tabs-separator-render (item face) + "Render ITEM using FACE." + (cond + ((and (listp item) (eq 'image (car item))) + (propertize " " 'display item + 'face face)) + (t item))) + +(defvar centaur-tabs-last-focused-buffer nil + "The last focused buffer.") + +(defvar centaur-tabs-last-focused-buffer-group nil + "The group name of last focused buffer.") + +(defun centaur-tabs-buffer-select-tab (tab) + "Select TAB." + (let ((buffer (centaur-tabs-tab-value tab)) + (group (centaur-tabs-tab-tabset tab))) + (switch-to-buffer buffer) + (setq centaur-tabs-last-focused-buffer buffer) + (setq centaur-tabs-last-focused-buffer-group group) + ;; (centaur-tabs-buffer-show-groups nil) + (centaur-tabs-display-update) + )) + +(defun centaur-tabs-buffer-track-killed () + "Hook run just before actually killing a buffer. +In Centaur-Tabs mode, try to switch to a buffer in the current tab bar, +after the current buffer has been killed. Try first the buffer in tab +after the current one, then the buffer in tab before. On success, put +the sibling buffer in front of the buffer list, so it will be selected +first." + (and (eq (eval centaur-tabs-display-line-format) centaur-tabs-header-line-format) + (eq centaur-tabs-current-tabset-function 'centaur-tabs-buffer-tabs) + (eq (current-buffer) (window-buffer (selected-window))) + (let ((bl (centaur-tabs-tab-values (centaur-tabs-current-tabset))) + (b (current-buffer)) + found sibling) + (while (and bl (not found)) + (if (eq b (car bl)) + (setq found t) + (setq sibling (car bl))) + (setq bl (cdr bl))) + (when (and (setq sibling (or (car bl) sibling)) + (buffer-live-p sibling)) + ;; Move sibling buffer in front of the buffer list. + (save-current-buffer + (switch-to-buffer sibling)))))) + +;; Buffer reordering +(defun centaur-tabs-remove-nth-element (nth list) + "Remove NTH element from LIST." + (if (zerop nth) (cdr list) + (let ((last (nthcdr (1- nth) list))) + (setcdr last (cddr last)) + list))) + +(defun centaur-tabs-insert-after (list aft-el el) + "Insert EL after AFT-EL in LIST." + (push el (cdr (member aft-el list))) + list) + +(defun centaur-tabs-insert-before (list bef-el el) + "Insert EL before BEF-EL in LIST." + (nreverse (centaur-tabs-insert-after (nreverse list) bef-el el))) + +(defun centaur-tabs-adjust-buffer-order () + "Put the two buffers switched to the adjacent position after current buffer changed." + ;; Don't trigger by centaur-tabs command, it's annoying. + ;; This feature should be trigger by search plugins, such as ibuffer, helm or ivy. + (unless (or (string-prefix-p "centaur-tabs" (format "%s" this-command)) + (string-prefix-p "mouse-drag-header-line" (format "%s" this-command)) + (string-prefix-p "mouse-drag-tab-line" (format "%s" this-command)) + (string-prefix-p "(lambda (event) (interactive e)" (format "%s" this-command))) + ;; Just continue when the buffer has changed. + (when (and centaur-tabs-adjust-buffer-order + (not (eq (current-buffer) centaur-tabs-last-focused-buffer)) + (not (minibufferp))) + (let* ((current (current-buffer)) + (previous centaur-tabs-last-focused-buffer) + (current-group (cl-first (funcall centaur-tabs-buffer-groups-function)))) + ;; Record the last focused buffer. + (setq centaur-tabs-last-focused-buffer current) + + ;; Just continue if two buffers are in the same group. + (when (string= current-group centaur-tabs-last-focused-buffer-group) + (let* ((bufset (centaur-tabs-get-tabset current-group)) + (current-group-tabs (centaur-tabs-tabs bufset)) + (current-group-buffers (cl-mapcar 'car current-group-tabs)) + (current-buffer-index (cl-position current current-group-buffers)) + (previous-buffer-index (cl-position previous current-group-buffers))) + + ;; If the tabs are not adjacent, swap their positions. + (when (and current-buffer-index + previous-buffer-index + (> (abs (- current-buffer-index previous-buffer-index)) 1)) + (let* ((copy-group-tabs (cl-copy-list current-group-tabs)) + (previous-tab (nth previous-buffer-index copy-group-tabs)) + (current-tab (nth current-buffer-index copy-group-tabs)) + (base-group-tabs (centaur-tabs-remove-nth-element current-buffer-index copy-group-tabs)) + new-group-tabs) + (cond + ((eq centaur-tabs-adjust-buffer-order 'left) + (setq new-group-tabs (centaur-tabs-insert-before base-group-tabs previous-tab current-tab))) + ((eq centaur-tabs-adjust-buffer-order 'right) + (setq new-group-tabs (centaur-tabs-insert-after base-group-tabs previous-tab current-tab))) + (t + (if (> current-buffer-index previous-buffer-index) + (setq new-group-tabs (centaur-tabs-insert-after base-group-tabs previous-tab current-tab)) + (setq new-group-tabs (centaur-tabs-insert-before base-group-tabs previous-tab current-tab))))) + (set bufset new-group-tabs) + (centaur-tabs-set-template bufset nil) + (centaur-tabs-display-update) + )))) + + ;; Update the group name of the last accessed tab. + (setq centaur-tabs-last-focused-buffer-group current-group))))) + +(defun centaur-tabs-adjust-buffer-order-alphabetically () + "Order tabs in group alphabetically." + ;; Don't trigger by centaur-tabs command, it's annoying. + (unless (or (string-prefix-p "centaur-tabs" (format "%s" this-command)) + (string-prefix-p "mouse-drag-header-line" (format "%s" this-command)) + (string-prefix-p "mouse-drag-tab-line" (format "%s" this-command)) + (string-prefix-p "(lambda (event) (interactive e)" (format "%s" this-command))) + ;; Just continue when the buffer has changed. + (when (and centaur-tabs-adjust-buffer-order + (not (eq (current-buffer) centaur-tabs-last-focused-buffer)) ;;??? + (not (minibufferp))) + (let* ((current (current-buffer)) + (current-group (cl-first (funcall centaur-tabs-buffer-groups-function)))) + (setq centaur-tabs-last-focused-buffer current) + ;; Just continue if two buffers are in the same group. + (when (string= current-group centaur-tabs-last-focused-buffer-group) + (let* ((bufset (centaur-tabs-get-tabset current-group)) + (current-group-tabs (centaur-tabs-tabs bufset))) + (setq new-group-tabs (sort current-group-tabs + (lambda (x y) + (string< (buffer-name (car x)) (buffer-name (car y)))))) + (set bufset new-group-tabs) + (centaur-tabs-set-template bufset nil) + (centaur-tabs-display-update))) + (setq centaur-tabs-last-focused-buffer-group current-group))))) + +(defun centaur-tabs-enable-buffer-reordering () + "Enable the buffer reordering functionality, according to buffer usage." + (add-hook 'post-command-hook centaur-tabs-adjust-buffer-order-function)) + +(defun centaur-tabs-enable-buffer-alphabetical-reordering () + "Enable the buffer alphabetical reordering functionality." + (setq centaur-tabs-adjust-buffer-order-function 'centaur-tabs-adjust-buffer-order-alphabetically) + (add-hook 'post-command-hook centaur-tabs-adjust-buffer-order-function)) + +;;; Buffer grouping and tab hiding +;; +(defun centaur-tabs-project-name () + "Get project name for tabs." + (let* ((project-current (project-current)) + (project-name (if (proper-list-p project-current) + (car (last project-current)) + (cdr project-current)))) + (if project-name + (format "Project: %s" (expand-file-name project-name)) + centaur-tabs-common-group-name))) + +;; Rules to control buffer's group rules. +(defvar centaur-tabs-groups-hash (make-hash-table :test 'equal)) +(defvar centaur-tabs-hide-hash (make-hash-table :test 'equal)) + +(defun centaur-tabs-get-group-name (buf) + "Get group name of buffer BUF." + (let ((group-name (gethash buf centaur-tabs-groups-hash))) + ;; Return group name cache if it exists for improve performance. + (if group-name + group-name + ;; Otherwise try get group name with `project-current'. + ;; `project-current' is very slow, it will slow down Emacs if you call it when switch buffer. + (with-current-buffer buf + (let ((project-name (centaur-tabs-project-name))) + (puthash buf project-name centaur-tabs-groups-hash) + project-name))))) + +(defun centaur-tabs-buffer-groups () + "`centaur-tabs-buffer-groups' control buffers' group rules. + +Group centaur-tabs with mode if buffer is derived from `eshell-mode' +`emacs-lisp-mode' `dired-mode' `org-mode' `magit-mode'. +All buffer name start with * will group to \"Emacs\". +Other buffer group by `centaur-tabs-get-group-name' with project name." + (list + (cond + ((or (string-equal "*" (substring (buffer-name) 0 1)) + (memq major-mode '(magit-process-mode + magit-status-mode + magit-diff-mode + magit-log-mode + magit-file-mode + magit-blob-mode + magit-blame-mode + ))) + "Emacs") + ((derived-mode-p 'eshell-mode) + "EShell") + ((derived-mode-p 'emacs-lisp-mode) + "Elisp") + ((derived-mode-p 'dired-mode) + "Dired") + ((memq major-mode '(org-mode org-agenda-mode diary-mode)) + "OrgMode") + (t + (centaur-tabs-get-group-name (current-buffer)))))) + +(defun centaur-tabs--create-new-empty-buffer () + "Open an Untitled buffer." + (interactive) + (let ((buf (generate-new-buffer "Untitled"))) + (switch-to-buffer buf) + (funcall (and initial-major-mode)) + (setq buffer-offer-save t))) + +(defun centaur-tabs--create-new-tab () + "Create a context-aware new tab." + (interactive) + (cond + ((eq major-mode 'eshell-mode) + (eshell t)) + ((eq major-mode 'vterm-mode) + (vterm t)) + ((eq major-mode 'term-mode) + (ansi-term "/bin/bash")) + ((derived-mode-p 'eww-mode) + (let ((current-prefix-arg 4)) + (call-interactively #'eww))) + (t + (centaur-tabs--create-new-empty-buffer)))) + +(defun centaur-tabs-hide-tab (x) + "Do no to show buffer X in tabs." + (let ((name (format "%s" x))) + (or + ;; Current window is not dedicated window. + (window-dedicated-p (selected-window)) + + ;; Buffer name not match below blacklist. + (cl-dolist (prefix centaur-tabs-excluded-prefixes) + (when (string-prefix-p prefix name) + (cl-return t))) + + ;; Is not magit buffer. + (and (string-prefix-p "magit" name) + (not (file-name-extension name))) + ))) + +(defun centaur-tabs-hide-tab-cached (buf) + "Cached vesion of `centaur-tabs-hide-tab' to improve performance. +Operates over buffer BUF" + (let ((hide (gethash buf centaur-tabs-hide-hash 'not-found))) + (when (eq hide 'not-found) + (setq hide (funcall centaur-tabs-hide-tab-function buf)) + (puthash buf hide centaur-tabs-hide-hash)) + hide)) + +;;;;;;;;;;;;;;;;;;;;;;; Utils functions ;;;;;;;;;;;;;;;;;;;;;;; +(defun centaur-tabs-get-groups () + "Refresh tabs groups." + (set centaur-tabs-tabsets-tabset (centaur-tabs-map-tabsets 'centaur-tabs-selected-tab)) + (cl-mapcar #'(lambda (group) + (format "%s" (cdr group))) + (centaur-tabs-tabs centaur-tabs-tabsets-tabset))) + +(defun centaur-tabs-get-extensions () + "Get file extension of tabs." + (set centaur-tabs-tabsets-tabset (centaur-tabs-map-tabsets 'centaur-tabs-selected-tab)) + (let (extension-names) + (mapc #'(lambda (buffer) + (with-current-buffer buffer + (when (string-equal 'current-group-name (cdr (centaur-tabs-selected-tab (centaur-tabs-current-tabset t)))) + (when (buffer-file-name buffer) + (add-to-list 'extension-names (file-name-extension (buffer-file-name buffer)))) + ))) + (buffer-list)) + extension-names)) + +(defcustom centaur-tabs-enable-ido-completion t + "Non-nil means use `ido-completing-read' for completing reads else `completing-read'." + :group 'centaur-tabs + :type 'boolean) + +(defun centaur-tabs-completing-read (prompt choices) + "Prompt user with PROMPT to select from CHOICES using a completing read. +Refer to the variable `centaur-tabs-enable-ido-completion'." + (interactive) + (if centaur-tabs-enable-ido-completion + (ido-completing-read prompt choices) + (completing-read prompt choices))) + +;;;;;;;;;;;;;;;;;;;;;;; Default configurations ;;;;;;;;;;;;;;;;;;;;;;; + +(mapc (lambda (hook) + (add-hook hook (lambda () + (if (boundp 'tab-line-format) + (setq-local tab-line-format nil) + (setq-local header-line-format nil)) + ))) + centaur-tabs-hide-tabs-hooks) + +(provide 'centaur-tabs-functions) + +;;; centaur-tabs-functions.el ends here diff --git a/code/elpa/centaur-tabs-20230109.457/centaur-tabs-interactive.el b/code/elpa/centaur-tabs-20230109.457/centaur-tabs-interactive.el new file mode 100644 index 0000000..e183435 --- /dev/null +++ b/code/elpa/centaur-tabs-20230109.457/centaur-tabs-interactive.el @@ -0,0 +1,627 @@ +;;; centaur-tabs-interactive.el --- centaur-tabs interactive functions and plugins support lexical-binding: t; -*- + +;; Copyright (C) 2019-2020 Emmanuel Bustos + +;; This file is not part of GNU Emacs. + +;; +;; This program is free software; you can redistribute it and/or +;; modify it under the terms of the GNU General Public License as +;; published by the Free Software Foundation; either version 2, or +;; (at your option) any later version. +;; +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +;; General Public License for more details. +;; +;; You should have received a copy of the GNU General Public License +;; along with this program; see the file COPYING. If not, write to +;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth +;; Floor, Boston, MA 02110-1301, USA. +;; +;;; Commentary: +;; This file contains centaur-tabs interactive functions and plugins support + +;;; Code: +;;; Requires +(require 'centaur-tabs-elements) +(require 'centaur-tabs-functions) +;;;;;;;;;;;;;;;;;;;;;;; Interactive functions ;;;;;;;;;;;;;;;;;;;;;;; + +(defun centaur-tabs-switch-group (&optional groupname) + "Switch tab groups using ido. GROUPNAME can optionaly be provided." + (interactive) + (let* ((tab-buffer-list (cl-mapcar + #'(lambda (b) + (with-current-buffer b + (list (current-buffer) + (buffer-name) + (funcall centaur-tabs-buffer-groups-function) ))) + (funcall centaur-tabs-buffer-list-function))) + (groups (centaur-tabs-get-groups)) + (group-name (or groupname (centaur-tabs-completing-read "Groups: " groups))) ) + (catch 'done + (mapc + #'(lambda (group) + (when (equal group-name (car (car (cdr (cdr group))))) + (throw 'done (switch-to-buffer (car (cdr group)))))) + tab-buffer-list) ))) + +(defun centaur-tabs-select-end-tab () + "Select end tab of current tabset." + (interactive) + (centaur-tabs-select-beg-tab t)) + +(defun centaur-tabs-select-beg-tab (&optional backward) + "Select beginning tab of current tabs. +If BACKWARD is non-nil, move backward, otherwise move forward. +TYPE is default option." + (interactive) + (let* ((tabset (centaur-tabs-current-tabset t)) + (ttabset (centaur-tabs-get-tabsets-tabset)) + (_cycle (if (and (eq centaur-tabs-cycle-scope 'groups) + (not (cdr (centaur-tabs-tabs ttabset)))) + 'tabs + centaur-tabs-cycle-scope)) + _selected tab) + (when tabset + (setq tabset (centaur-tabs-tabs tabset) + tab (car (if backward (last tabset) tabset))) + (centaur-tabs-buffer-select-tab tab)))) + +(defun centaur-tabs-backward-tab-other-window (&optional reversed) + "Move to left tab in other window. +Optional argument REVERSED default is move backward, if reversed is non-nil move forward." + (interactive) + (other-window 1) + (if reversed + (centaur-tabs-forward-tab) + (centaur-tabs-backward-tab)) + (other-window -1)) + +(defun centaur-tabs-forward-tab-other-window () + "Move to right tab in other window." + (interactive) + (centaur-tabs-backward-tab-other-window t)) + +(defun centaur-tabs-move-current-tab-to-right () + "Move current tab one place right, unless it's already the rightmost." + (interactive) + (let* ((bufset (centaur-tabs-current-tabset t)) + (old-bufs (centaur-tabs-tabs bufset)) + (new-bufs (list)) + the-buffer) + (while (and + old-bufs + (not (string= (buffer-name) (format "%s" (car (car old-bufs)))))) + (push (car old-bufs) new-bufs) + (setq old-bufs (cdr old-bufs))) + (if old-bufs ; if this is false, then the current tab's buffer name is mysteriously missing + (progn + (setq the-buffer (car old-bufs)) + (setq old-bufs (cdr old-bufs)) + (if old-bufs ; if this is false, then the current tab is the rightmost + (push (car old-bufs) new-bufs)) + (push the-buffer new-bufs)) ; this is the tab that was to be moved + (error "Error: current buffer's name was not found in Centaur-Tabs's buffer list")) + (setq new-bufs (reverse new-bufs)) + (setq new-bufs (append new-bufs (cdr old-bufs))) + (set bufset new-bufs) + (centaur-tabs-set-template bufset nil) + (centaur-tabs-display-update))) + +(defun centaur-tabs-move-current-tab-to-left () + "Move current tab one place left, unless it's already the leftmost." + (interactive) + (let* ((bufset (centaur-tabs-current-tabset t)) + (old-bufs (centaur-tabs-tabs bufset)) + (first-buf (car old-bufs)) + (new-bufs (list)) + not-yet-this-buf) + (if (string= (buffer-name) (format "%s" (car first-buf))) + old-bufs ; the current tab is the leftmost + (setq not-yet-this-buf first-buf) + (setq old-bufs (cdr old-bufs)) + (while (and + old-bufs + (not (string= (buffer-name) (format "%s" (car (car old-bufs)))))) + (push not-yet-this-buf new-bufs) + (setq not-yet-this-buf (car old-bufs)) + (setq old-bufs (cdr old-bufs))) + (if old-bufs ; if this is false, then the current tab's buffer name is mysteriously missing + (progn + (push (car old-bufs) new-bufs) ; this is the tab that was to be moved + (push not-yet-this-buf new-bufs) + (setq new-bufs (reverse new-bufs)) + (setq new-bufs (append new-bufs (cdr old-bufs)))) + (error "Error: current buffer's name was not found in Centaur-Tabs's buffer list")) + (set bufset new-bufs) + (centaur-tabs-set-template bufset nil) + (centaur-tabs-display-update)))) + +(defmacro centaur-tabs-kill-buffer-match-rule (match-rule) + "If buffer match MATCH-RULE, kill it." + `(save-excursion + (mapc #'(lambda (buffer) + (with-current-buffer buffer + (when (string-equal current-group-name (cdr (centaur-tabs-selected-tab (centaur-tabs-current-tabset t)))) + (when (funcall ,match-rule buffer) + (kill-buffer buffer)) + ))) + (buffer-list)))) + +(defun centaur-tabs-kill-all-buffers-in-current-group () + "Kill all buffers in current group." + (interactive) + (let* ((current-group-name (cdr (centaur-tabs-selected-tab (centaur-tabs-current-tabset t))))) + ;; Kill all buffers in current group. + (centaur-tabs-kill-buffer-match-rule + (lambda (_buffer) t)) + ;; Switch to next group. + (centaur-tabs-forward-group) + )) + +(defun centaur-tabs-kill-other-buffers-in-current-group () + "Kill all buffers except current buffer in current group." + (interactive) + (let* ((current-group-name (cdr (centaur-tabs-selected-tab (centaur-tabs-current-tabset t)))) + (currentbuffer (current-buffer))) + ;; Kill all buffers in current group. + (centaur-tabs-kill-buffer-match-rule + (lambda (buffer) (not (equal buffer currentbuffer)))) + )) + +(defun centaur-tabs-kill-unmodified-buffers-in-current-group () + "Kill all unmodified buffer in current group." + (interactive) + (let* ((current-group-name (cdr (centaur-tabs-selected-tab (centaur-tabs-current-tabset t)))) + (currentbuffer (current-buffer))) + ;; Kill all buffers in current group. + (centaur-tabs-kill-buffer-match-rule + (lambda (buffer) (not (buffer-modified-p buffer)))) + )) + + +(defun centaur-tabs-kill-match-buffers-in-current-group () + "Kill all buffers match extension in current group." + (interactive) + (let* ((current-group-name (cdr (centaur-tabs-selected-tab (centaur-tabs-current-tabset t)))) + (extension-names (centaur-tabs-get-extensions)) + match-extension) + ;; Read extension need to kill. + (setq match-extension (centaur-tabs-completing-read "Kill buffers suffix with: " extension-names)) + ;; Kill all buffers match extension in current group. + (centaur-tabs-kill-buffer-match-rule + (lambda (buffer) + (let ((filename (buffer-file-name buffer))) + (and filename (string-equal (file-name-extension filename) match-extension)) + ))) + ;; Switch to next group if last file killed. + (when (equal (length extension-names) 1) + (centaur-tabs-forward-group)) + )) + +(defun centaur-tabs-keep-match-buffers-in-current-group () + "Keep all buffers match extension in current group." + (interactive) + (let* ((current-group-name (cdr (centaur-tabs-selected-tab (centaur-tabs-current-tabset t)))) + (extension-names (centaur-tabs-get-extensions)) + match-extension) + ;; Read extension need to kill. + (setq match-extension (centaur-tabs-completing-read "Just keep buffers suffix with: " extension-names)) + ;; Kill all buffers match extension in current group. + (centaur-tabs-kill-buffer-match-rule + (lambda (buffer) + (let ((filename (buffer-file-name buffer))) + (and filename (not (string-equal (file-name-extension filename) match-extension))) + ))) + ;; Switch to next group if last file killed. + (when (equal (length extension-names) 1) + (centaur-tabs-forward-group)) + )) + +(defun centaur-tabs-select-visible-nth-tab (tab-index) + "Select visible tab with TAB-INDEX'. +Example, when `tab-index' is 1, this function will select the leftmost label in +the visible area, instead of the first label in the current group. +If `tab-index' more than length of visible tabs, selet the last tab. + +If `tab-index' is 0, select last tab." + (let ((visible-tabs (centaur-tabs-view centaur-tabs-current-tabset))) + (switch-to-buffer + (car + (if (or (equal tab-index 0) + (> tab-index (length visible-tabs))) + (car (last visible-tabs)) + (nth (- tab-index 1) visible-tabs)))))) + +(defun centaur-tabs-select-visible-tab () + "Bind this function with number keystroke, such as s-1, s-2, s-3 ... etc. + +This function automatically recognizes the number at the end of the keystroke +and switches to the tab of the corresponding index. + +Note that this function switches to the visible range, +not the actual logical index position of the current group." + (interactive) + (let* ((event last-command-event) + (key (make-vector 1 event)) + (key-desc (key-description key))) + (centaur-tabs-select-visible-nth-tab + (string-to-number (car (last (split-string key-desc "-"))))))) + +;; ace-jump style tab switching + +(defvar centaur-tabs-ace-jump-active nil + "t if centaur-tabs-ace-jump is invoked.") + +(defvar centaur-tabs-dim-overlay nil + "Holds the overlay for dimming buffer when invoking centaur-tabs-ace-jump.") + +(defun centaur-tabs--dim-window () + "Create a dim background overlay for the current window." + (when centaur-tabs-ace-jump-dim-buffer + (when centaur-tabs-dim-overlay + (delete-overlay centaur-tabs-dim-overlay)) + (setq centaur-tabs-dim-overlay + (let ((ol (make-overlay (window-start) (window-end)))) + (overlay-put ol 'face 'centaur-tabs-dim-buffer-face) + ol)))) + +(defun centaur-tabs-swap-tab (tab) + "Swap the position of current tab with TAB. +TAB has to be in the same group as the current tab." + (if (eq (centaur-tabs-tab-tabset tab) (centaur-tabs-current-tabset t)) + (let* ((group (centaur-tabs-current-tabset t)) + (tabs (cl-copy-list (centaur-tabs-tabs group))) + (current (centaur-tabs-selected-tab group)) + (current-index (cl-position current tabs)) + (target-index (cl-position tab tabs))) + (if (eq tab current) + (message "Can't swap with current tab itself.") + (setcar (nthcdr current-index tabs) tab) + (setcar (nthcdr target-index tabs) current) + (set group tabs) + (centaur-tabs-set-template (centaur-tabs-current-tabset t) nil) + (centaur-tabs-display-update))) + (message "Error: %s is not in the same group as the current tab." tab))) + +(defun centaur-tabs-ace-action (action) + "Preform ACTION on a visible tab. Ace-jump style. +ACTION has to be one of value in `centuar-tabs-ace-dispatch-alist'" + (when (centaur-tabs-current-tabset t) + (when centaur-tabs-ace-jump-dim-buffer + (centaur-tabs--dim-window)) + (cond ((eq action 'jump-to-tab) + (message "Jump to tab: ")) + ((eq action 'close-tab) + (message "Close tab: ")) + ((eq action 'swap-tab) + (message "Swap current tab with: "))) + + (let ((centaur-tabs-ace-jump-active t)) + (catch 'done + (while t + (centaur-tabs-set-template (centaur-tabs-current-tabset t) nil) + (centaur-tabs-display-update) + (let ((char (read-key)) (action-cache)) + (cond + ;; tab keys + ((memq char centaur-tabs-ace-jump-keys) + (let ((sel (nth (cl-position char centaur-tabs-ace-jump-keys) (centaur-tabs-view (centaur-tabs-current-tabset t))))) + (cond ((eq sel nil) + (message "Tab %s does not exist" (key-description (vector char)))) + ((eq action 'jump-to-tab) + (centaur-tabs-buffer-select-tab sel)) + ((eq action 'close-tab) + (centaur-tabs-buffer-close-tab sel)) + ((eq action 'swap-tab) + (centaur-tabs-swap-tab sel)))) + (throw 'done nil)) + ;; actions + ((setq action-cache (assoc char centuar-tabs-ace-dispatch-alist)) + (setq action-cache (cadr action-cache)) + (cond ((eq action-cache 'exit) ; exit + (message "Quit") + (throw 'done nil)) + ((eq action-cache 'forward-group) ; forward group + (message "Forward group") + (centaur-tabs-forward-group) + (centaur-tabs--dim-window)) + ((eq action-cache 'backward-group) ; backward group + (message "Backward group") + (centaur-tabs-backward-group) + (centaur-tabs--dim-window)) + ((eq action-cache 'show-help) ; help menu + (message "%s" (mapconcat + (lambda (elem) (format "%s: %s" + (key-description (vector (car elem))) + (caddr elem))) + centuar-tabs-ace-dispatch-alist + "\n"))) + (t (setq action action-cache) ; other actions + (cond ((eq action-cache 'jump-to-tab) + (message "Jump to tab: ")) + ((eq action-cache 'close-tab) + (message "Close tab: ")) + ((eq action-cache 'swap-tab) + (message "Swap current tab with: ")))))) + ;; no match, repeat + (t + (message "No such candidate: %s, hit ? for help." (key-description (vector char))))))))) + (centaur-tabs-set-template (centaur-tabs-current-tabset t) nil) + (when centaur-tabs-ace-jump-dim-buffer + (delete-overlay centaur-tabs-dim-overlay) + (setq centaur-tabs-dim-overlay nil)) + (centaur-tabs-display-update))) + +(defun centaur-tabs-ace-jump (&optional arg) + "Select a tab and perform an action. Ace-jump style. +If no ARG is provided, select that tab. +If prefixed with one `universal-argument', swap the current +tab with the selected tab. +If prefixed with two `universal-argument's, close +selected tab." + (interactive "p") + (cond ((eq arg 1) + (centaur-tabs-ace-action 'jump-to-tab)) + ((eq arg 4) + (centaur-tabs-ace-action 'swap-tab)) + ((eq arg 16) + (centaur-tabs-ace-action 'close-tab)) + (t + (centaur-tabs-ace-action 'jump-to-tab)))) + +(defun centaur-tabs-group-buffer-groups () + "Use centaur-tabs's own buffer grouping function." + (interactive) + (setq centaur-tabs-buffer-groups-function 'centaur-tabs-buffer-groups) + (centaur-tabs-display-update)) + +;; Projectile integration. Taken from tabbar-ruler +(defvar centaur-tabs-projectile-buffer-group-calc nil + "Set buffer groups for projectile. +Should be buffer local and speed up calculation of buffer groups.") + +(defun centaur-tabs-projectile-buffer-groups () + "Return the list of group names BUFFER belongs to." + (if centaur-tabs-projectile-buffer-group-calc + (symbol-value 'centaur-tabs-projectile-buffer-group-calc) + (set (make-local-variable 'centaur-tabs-projectile-buffer-group-calc) + + (cond + ((or (get-buffer-process (current-buffer)) (memq major-mode '(comint-mode compilation-mode))) '("Term")) + ((string-equal "*" (substring (buffer-name) 0 1)) '("Misc")) + ((condition-case _err + (projectile-project-root) + (error nil)) (list (projectile-project-name))) + ((memq major-mode '(emacs-lisp-mode python-mode emacs-lisp-mode c-mode + c++-mode javascript-mode js-mode + js2-mode makefile-mode + lua-mode vala-mode)) '("Coding")) + ((memq major-mode '(nxhtml-mode html-mode + mhtml-mode css-mode)) '("HTML")) + ((memq major-mode '(org-mode calendar-mode diary-mode)) '("Org")) + ((memq major-mode '(dired-mode)) '("Dir")) + (t '("Other")))) + (symbol-value 'centaur-tabs-projectile-buffer-group-calc))) + +(defun centaur-tabs-group-by-projectile-project() + "Group by projectile project." + (interactive) + (setq centaur-tabs-buffer-groups-function 'centaur-tabs-projectile-buffer-groups) + (centaur-tabs-display-update)) + +;; Show groups instead of tabs +(defun centaur-tabs-toggle-groups () + "Show group names on the tabs instead of buffer names." + (interactive) + (centaur-tabs-buffer-show-groups (not centaur-tabs--buffer-show-groups)) + (centaur-tabs-display-update)) + +;; Helm source for switching group in helm. + +(defun centaur-tabs-build-helm-source () + "Display a list of current buffer groups in Helm." + (interactive) + (setq helm-source-centaur-tabs-group + (when (featurep 'helm) + (require 'helm) + (helm-build-sync-source "Centaur-Tabs Group" + :candidates #'centaur-tabs-get-groups + :action '(("Switch to group" . centaur-tabs-switch-group)))))) + +;; Ivy source for switching group in ivy. + +;;;###autoload +(defun centaur-tabs-counsel-switch-group () + "Display a list of current buffer groups using Counsel." + (interactive) + (when (featurep 'ivy) + (require 'ivy) + (ivy-read + "Centaur Tabs Groups:" + (centaur-tabs-get-groups) + :action #'centaur-tabs-switch-group + :caller 'centaur-tabs-counsel-switch-group))) + + +(defun centaur-tabs-extract-window-to-new-frame() + "Kill the current window in the current frame, and open the current buffer in a new frame." + (interactive) + (unless (centaur-tabs--one-window-p) + (let ((buffer (current-buffer))) + (delete-window) + (display-buffer-pop-up-frame buffer nil)))) + +(defun centaur-tabs--copy-file-name-to-clipboard () + "Copy the current buffer file name to the clipboard." + ;;; From https://emacsredux.com/blog/2013/03/27/copy-filename-to-the-clipboard/ + (interactive) + (let* ((filename (if (equal major-mode 'dired-mode) + default-directory + (buffer-file-name))) + (filename (expand-file-name filename))) + (when filename + (kill-new filename) + (message "Copied buffer file name '%s' to the kill ring." filename)))) + + +(defun centaur-tabs-open-directory-in-external-application () + "Open the current directory in a external application." + (interactive) + (centaur-tabs--open-externally default-directory)) + +(defun centaur-tabs-open-in-external-application () + "Open the file of the current buffer according to its mime type." + (interactive) + (let ((path (if (buffer-file-name) (buffer-file-name) default-directory))) + (centaur-tabs--open-externally path))) + +(defun centaur-tabs--open-externally (file-or-path) + "Open FILE-OR-PATH according to its mime type in an external application. +FILE-OR-PATH is expanded with `expand-file-name`. +Modified copy of `treemacs-visit-node-in-external-application`." + (let ((path (expand-file-name file-or-path))) + (pcase system-type + ('windows-nt + (declare-function w32-shell-execute "w32fns.c") + (w32-shell-execute "open" (replace-regexp-in-string "/" "\\" path t t))) + ('darwin + (shell-command (format "open \"%s\"" path))) + ('gnu/linux + (let ((process-connection-type nil)) + (start-process "" nil "xdg-open" path))) + (_ (message "Don't know how to open files on %s." (symbol-name system-type)))))) + + +(defun centaur-tabs--copy-directory-name-to-clipboard () + "Copy the current directory name to the clipboard." + (interactive) + (when default-directory + (kill-new default-directory) + (message "Copied directory name '%s' to the kill ring." (expand-file-name default-directory)))) + +(defun centaur-tabs--tab-submenu-groups-definition () + "Menu definition with a list of tab groups." + (mapcar (lambda (s) `[,s ,s]) (sort (centaur-tabs-get-groups) #'string<))) + + +(defun centaur-tabs--tab-submenu-tabs-definition () + "Menu definition with a list of tabs for the current group." + (let* ((tabset (centaur-tabs-get-tabset centaur-tabs-last-focused-buffer-group)) + (tabs-in-group (centaur-tabs-tabs tabset)) + (buffers (mapcar #'centaur-tabs-tab-value tabs-in-group)) + (sorted-tabnames (sort (mapcar #'buffer-name buffers) #'string<))) + (mapcar (lambda (s) `[,s ,s]) sorted-tabnames))) + + + +(defvar centaur-tabs--groups-submenu-key "Tab groups") +(defvar centaur-tabs--tabs-submenu-key "Go to tab of group") + + + +(defun centaur-tabs--kill-this-buffer-dont-ask() + "Kill the current buffer without confirmation." + (interactive) + (kill-buffer (current-buffer)) + (centaur-tabs-display-update) + (redisplay t)) + + +(defun centaur-tabs--tab-menu-definition () + "Definition of the context menu of a tab." + `(["Kill this buffer" centaur-tabs--kill-this-buffer-dont-ask] + ["Kill other buffers of group" centaur-tabs-kill-other-buffers-in-current-group] + ["Kill unmodified buffers of group" centaur-tabs-kill-unmodified-buffers-in-current-group] + "----" + ["Split below" split-window-below] + ["Split right" split-window-right] + "----" + ["Maximize tab" delete-other-windows + :active (null (centaur-tabs--one-window-p))] + ["Extract to new frame" centaur-tabs-extract-window-to-new-frame + :active (null (centaur-tabs--one-window-p))] + ["Duplicate in new frame" make-frame-command] + "----" + ["Copy filepath" centaur-tabs--copy-file-name-to-clipboard + :active (buffer-file-name)] + ["Copy directory path" centaur-tabs--copy-directory-name-to-clipboard + :active default-directory] + ["Open in external application" centaur-tabs-open-in-external-application + :active (or (buffer-file-name) default-directory)] + ["Open directory in dired" dired-jump + :active (not (eq major-mode 'dired-mode))] + ["Open directory externally" centaur-tabs-open-directory-in-external-application + :active default-directory] + "----" + ,( append (list centaur-tabs--groups-submenu-key) (centaur-tabs--tab-submenu-groups-definition)) + ,( append (list centaur-tabs--tabs-submenu-key) (centaur-tabs--tab-submenu-tabs-definition)) + )) + +(defun centaur-tabs--one-window-p () + "Like `one-window-p`, but taking into account side windows like treemacs." + (let* ((mainwindow (window-main-window)) + (child-count (window-child-count mainwindow))) + (= 0 child-count))) + +(defun centaur-tabs--get-tab-from-name (tabname) + "Get the tab from the current group given de TABNAME." + (let ((seq (centaur-tabs-tabs (centaur-tabs-get-tabset centaur-tabs-last-focused-buffer-group)))) + (cl-find-if + (lambda (tab) (string= tabname (buffer-name (centaur-tabs-tab-value tab)))) + seq))) + + +(defun centaur-tabs--tab-menu (event) + "Show a context menu for the clicked tab or button. The clicked tab, identified by EVENT, is selected." + (interactive "e" ) + + (let ((click-on-tab-p (ignore-errors (centaur-tabs-get-tab-from-event event)))) + + (when (not click-on-tab-p) + (centaur-tabs--groups-menu)) + + (when click-on-tab-p + (centaur-tabs-do-select event) + (redisplay t) + + (let* + ((menu (easy-menu-create-menu nil (centaur-tabs--tab-menu-definition))) + (choice (x-popup-menu t menu)) + (action (lookup-key menu (apply 'vector choice))) + (action-is-command-p (and (commandp action) (functionp action)))) + (when action-is-command-p + (call-interactively action)) + (when (not action-is-command-p) + (let* ((menu-key (first choice)) + (choice-is-group-p (string= centaur-tabs--groups-submenu-key (symbol-name menu-key))) + (name (car (last choice))) + (name-as-string (symbol-name name))) + (if choice-is-group-p + (centaur-tabs-switch-group name-as-string) + (switch-to-buffer name-as-string)))))))) + + +(defun centaur-tabs--groups-menu () + "Show a popup menu with the centaur tabs groups." + (interactive) + + (let* + ((sorted-groups (centaur-tabs--tab-submenu-groups-definition)) + (menu (easy-menu-create-menu "Tab groups" (centaur-tabs--tab-submenu-groups-definition))) + (choice (x-popup-menu t menu)) + (action (lookup-key menu (apply 'vector choice))) + (action-is-command-p (and (commandp action) (functionp action)))) + (when action-is-command-p + (call-interactively action)) + (when (not action-is-command-p) + (let ((group (car (last choice)))) + (centaur-tabs-switch-group (format "%s" group)))))) + + +(provide 'centaur-tabs-interactive) + +;;; centaur-tabs-interactive.el ends here diff --git a/code/elpa/centaur-tabs-20230109.457/centaur-tabs-pkg.el b/code/elpa/centaur-tabs-20230109.457/centaur-tabs-pkg.el new file mode 100644 index 0000000..460e38a --- /dev/null +++ b/code/elpa/centaur-tabs-20230109.457/centaur-tabs-pkg.el @@ -0,0 +1,12 @@ +(define-package "centaur-tabs" "20230109.457" "Aesthetic, modern looking customizable tabs plugin" + '((emacs "24.4") + (powerline "2.4") + (cl-lib "0.5")) + :commit "a2890d968d877b269a814a691356fc5877833c39" :authors + '(("Emmanuel Bustos" . "ema2159@gmail.com")) + :maintainer + '("Emmanuel Bustos" . "ema2159@gmail.com") + :url "https://github.com/ema2159/centaur-tabs") +;; Local Variables: +;; no-byte-compile: t +;; End: diff --git a/code/elpa/centaur-tabs-20230109.457/centaur-tabs.el b/code/elpa/centaur-tabs-20230109.457/centaur-tabs.el new file mode 100644 index 0000000..8fd4c77 --- /dev/null +++ b/code/elpa/centaur-tabs-20230109.457/centaur-tabs.el @@ -0,0 +1,218 @@ +;;; centaur-tabs.el --- Aesthetic, modern looking customizable tabs plugin -*- lexical-binding: t; -*- + +;; Copyright (C) 2019 Emmanuel Bustos + +;; Filename: centaur-tabs.el +;; Description: Provide an out of box configuration to use highly customizable tabs. +;; URL: https://github.com/ema2159/centaur-tabs +;; Author: Emmanuel Bustos +;; Maintainer: Emmanuel Bustos +;; Created: 2019-21-19 22:14:34 +;; Version: 5 +;; Known Compatibility: GNU Emacs 26.2 +;; Package-Requires: ((emacs "24.4") (powerline "2.4") (cl-lib "0.5")) +;; +;; + +;;; This file is NOT part of GNU Emacs + +;;; License +;; +;; This program is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation; either version 3, or (at your option) +;; any later version. + +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with this program; see the file COPYING. If not, write to +;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth +;; Floor, Boston, MA 02110-1301, USA. + +;;; Commentary: +;; +;; Emacs plugin aiming to become an aesthetic, modern looking tabs plugin. +;; +;; This package offers tabs with a wide range of customization options, both +;; aesthetical and functional, implementing them trying to follow the Emacs +;; philosophy packing them with useful keybindings and a nice integration +;; with the Emacs environment, without sacrificing customizability. +;; Some of the features Centaur tabs offers are: +;; - Tab styles +;; - Tab icons +;; - Graying out icons +;; - Selected tab bar (over, under and left bar) +;; - Close button +;; - Modified marker +;; - Buffer grouping +;; - Projectile integration +;; - Ivy and Helm integration for group switching +;; + +;;; Code: +;;; Requires +(require 'centaur-tabs-elements) +(require 'centaur-tabs-functions) +(require 'centaur-tabs-interactive) +;;;;;;;;;;;;;;;;;;;;;;; Centaur-Tabs source code ;;;;;;;;;;;;;;;;;;;;;;; + +(defgroup centaur-tabs nil + "Display a tab bar in the header line." + :group 'convenience) + +(defvar centaur-tabs--buffer-show-groups nil) + +;;; Minor modes +;; +(defsubst centaur-tabs-mode-on-p () + "Return non-nil if Centaur-Tabs mode is on." + (eq (default-value centaur-tabs-display-line-format) + centaur-tabs-header-line-format)) + +;;; Centaur-Tabs-Local mode +;; +(defvar centaur-tabs--local-hlf nil) + +;;;###autoload +(define-minor-mode centaur-tabs-local-mode + "Toggle local display of the tab bar. +With prefix argument ARG, turn on if positive, otherwise off. +Returns non-nil if the new state is enabled. +When turned on, if a local header line is shown, it is hidden to show +the tab bar. The tab bar is locally hidden otherwise. When turned +off, if a local header line is hidden or the tab bar is locally +hidden, it is shown again. Signal an error if Centaur-Tabs mode is off." + :group 'centaur-tabs + :global nil + (unless (centaur-tabs-mode-on-p) + (error "Centaur-Tabs mode must be enabled")) +;;; ON + (if centaur-tabs-local-mode + (if (and (local-variable-p centaur-tabs-display-line-format) + (eval centaur-tabs-display-line-format)) + ;; A local header line exists, hide it to show the tab bar. + (progn + ;; Fail in case of an inconsistency because another local + ;; header line is already hidden. + (when (local-variable-p 'centaur-tabs--local-hlf) + (error "Another local header line is already hidden")) + (set (make-local-variable 'centaur-tabs--local-hlf) + (eval centaur-tabs-display-line-format)) + (kill-local-variable centaur-tabs-display-line-format)) + ;; Otherwise hide the tab bar in this buffer. + (set centaur-tabs-display-line-format nil)) +;;; OFF + (if (local-variable-p 'centaur-tabs--local-hlf) + ;; A local header line is hidden, show it again. + (progn + (set centaur-tabs-display-line-format centaur-tabs--local-hlf) + (kill-local-variable 'centaur-tabs--local-hlf)) + ;; The tab bar is locally hidden, show it again. + (kill-local-variable centaur-tabs-display-line-format)))) + +;;; Centaur-Tabs mode +;; +(defvar centaur-tabs--global-hlf nil) + +;;;###autoload +(define-minor-mode centaur-tabs-mode + "Toggle display of a tab bar in the header line. +With prefix argument ARG, turn on if positive, otherwise off. +Returns non-nil if the new state is enabled. + +\\{centaur-tabs-mode-map}" + :group 'centaur-tabs + :require 'centaur-tabs + :global t + :keymap centaur-tabs-mode-map + (if centaur-tabs-mode +;;; ON + (unless (centaur-tabs-mode-on-p) + ;; Save current default value of `centaur-tabs-display-line-format'. + (setq centaur-tabs--global-hlf (default-value centaur-tabs-display-line-format)) + (centaur-tabs-init-tabsets-store) + (set-default centaur-tabs-display-line-format centaur-tabs-header-line-format)) +;;; OFF + (when (centaur-tabs-mode-on-p) + ;; Turn off Centaur-Tabs-Local mode globally. + (mapc #'(lambda (b) + (condition-case nil + (with-current-buffer b + (and centaur-tabs-local-mode + (centaur-tabs-local-mode -1))) + (error nil))) + (buffer-list)) + ;; Restore previous `centaur-tabs-display-line-format'. + (set-default centaur-tabs-display-line-format centaur-tabs--global-hlf) + (centaur-tabs-free-tabsets-store)) + )) + +;;; Tab bar buffer setup +;; +(defun centaur-tabs-buffer-init () + "Initialize tab bar buffer data. +Run as `centaur-tabs-init-hook'." + (setq centaur-tabs--buffers nil + centaur-tabs-current-tabset-function 'centaur-tabs-buffer-tabs + centaur-tabs-tab-label-function 'centaur-tabs-buffer-tab-label + centaur-tabs-select-tab-function 'centaur-tabs-buffer-select-tab + ) + ;; If set, initialize selected overline + (when (eq centaur-tabs-set-bar 'under) + (set-face-attribute 'centaur-tabs-selected nil + :underline (face-background 'centaur-tabs-active-bar-face nil 'default) + :overline nil) + (set-face-attribute 'centaur-tabs-selected-modified nil + :underline (face-background 'centaur-tabs-active-bar-face nil 'default) + :overline nil) + (set-face-attribute 'centaur-tabs-unselected nil + :underline nil + :overline nil) + (set-face-attribute 'centaur-tabs-unselected-modified nil + :underline nil + :overline nil)) + (when (eq centaur-tabs-set-bar 'over) + (set-face-attribute 'centaur-tabs-selected nil + :overline (face-background 'centaur-tabs-active-bar-face nil 'default) + :underline nil) + (set-face-attribute 'centaur-tabs-selected-modified nil + :overline (face-background 'centaur-tabs-active-bar-face nil 'default) + :underline nil) + (set-face-attribute 'centaur-tabs-unselected nil + :overline nil + :underline nil) + (set-face-attribute 'centaur-tabs-unselected-modified nil + :overline nil + :underline nil)) + (add-hook 'after-save-hook #'centaur-tabs-on-saving-buffer) + (add-hook 'first-change-hook #'centaur-tabs-on-modifying-buffer) + (add-hook 'kill-buffer-hook #'centaur-tabs-buffer-track-killed) + (advice-add #'undo :after #'centaur-tabs-after-modifying-buffer) + (advice-add #'undo-tree-undo-1 :after #'centaur-tabs-after-modifying-buffer) + (advice-add #'undo-tree-redo-1 :after #'centaur-tabs-after-modifying-buffer)) + +(defun centaur-tabs-buffer-quit () + "Quit tab bar buffer. +Run as `centaur-tabs-quit-hook'." + (setq centaur-tabs--buffers nil + centaur-tabs-current-tabset-function nil + centaur-tabs-tab-label-function nil + centaur-tabs-select-tab-function nil + ) + (remove-hook 'after-save-hook 'centaur-tabs-after-modifying-buffer) + (remove-hook 'first-change-hook 'centaur-tabs-on-modifying-buffer) + (remove-hook 'kill-buffer-hook 'centaur-tabs-buffer-track-killed) + (advice-remove #'undo #'centaur-tabs-after-modifying-buffer) + (advice-remove #'undo-tree-undo-1 #'centaur-tabs-after-modifying-buffer) + (advice-remove #'undo-tree-redo-1 #'centaur-tabs-after-modifying-buffer)) + +(add-hook 'centaur-tabs-init-hook #'centaur-tabs-buffer-init) +(add-hook 'centaur-tabs-quit-hook #'centaur-tabs-buffer-quit) + +(provide 'centaur-tabs) + +;;; centaur-tabs.el ends here diff --git a/code/elpa/powerline-20221110.1956/powerline-autoloads.el b/code/elpa/powerline-20221110.1956/powerline-autoloads.el new file mode 100644 index 0000000..d9c0616 --- /dev/null +++ b/code/elpa/powerline-20221110.1956/powerline-autoloads.el @@ -0,0 +1,94 @@ +;;; powerline-autoloads.el --- automatically extracted autoloads -*- lexical-binding: t -*- +;; +;;; Code: + +(add-to-list 'load-path (directory-file-name + (or (file-name-directory #$) (car load-path)))) + + +;;;### (autoloads nil "powerline" "powerline.el" (0 0 0 0)) +;;; Generated autoloads from powerline.el + +(autoload 'powerline-hud "powerline" "\ +Return XPM of relative buffer location using FACE1 and FACE2 of optional WIDTH. + +\(fn FACE1 FACE2 &optional WIDTH)" nil nil) + +(autoload 'powerline-mouse "powerline" "\ +Return mouse handler for CLICK-GROUP given CLICK-TYPE and STRING. + +\(fn CLICK-GROUP CLICK-TYPE STRING)" nil nil) + +(autoload 'powerline-concat "powerline" "\ +Concatonate STRINGS and pad sides by spaces. + +\(fn &rest STRINGS)" nil nil) + +(autoload 'defpowerline "powerline" "\ +Create function NAME by wrapping BODY with powerline padding an propetization. + +\(fn NAME BODY)" nil t) + +(autoload 'powerline-raw "powerline" "\ +Render STR as mode-line data using FACE and optionally PAD import. +PAD can be left (`l') or right (`r'). + +\(fn STR &optional FACE PAD)" nil nil) + +(autoload 'powerline-fill "powerline" "\ +Return empty space using FACE and leaving RESERVE space on the right. + +\(fn FACE RESERVE)" nil nil) + (autoload 'powerline-major-mode "powerline") + (autoload 'powerline-minor-modes "powerline") + (autoload 'powerline-narrow "powerline") + (autoload 'powerline-vc "powerline") + (autoload 'powerline-encoding "powerline") + (autoload 'powerline-buffer-size "powerline") + (autoload 'powerline-buffer-id "powerline") + (autoload 'powerline-process "powerline") + (autoload 'powerline-selected-window-active "powerline") + +(register-definition-prefixes "powerline" '("pl/" "powerline-")) + +;;;*** + +;;;### (autoloads nil "powerline-separators" "powerline-separators.el" +;;;;;; (0 0 0 0)) +;;; Generated autoloads from powerline-separators.el + +(register-definition-prefixes "powerline-separators" '("pl/" "powerline-image-apple-rgb")) + +;;;*** + +;;;### (autoloads nil "powerline-themes" "powerline-themes.el" (0 +;;;;;; 0 0 0)) +;;; Generated autoloads from powerline-themes.el + +(autoload 'powerline-default-theme "powerline-themes" "\ +Setup the default mode-line." t nil) + +(autoload 'powerline-center-theme "powerline-themes" "\ +Setup a mode-line with major and minor modes centered." t nil) + +(autoload 'powerline-vim-theme "powerline-themes" "\ +Setup a Vim-like mode-line." t nil) + +(autoload 'powerline-nano-theme "powerline-themes" "\ +Setup a nano-like mode-line." t nil) + +(register-definition-prefixes "powerline-themes" '("powerline-")) + +;;;*** + +;;;### (autoloads nil nil ("powerline-pkg.el") (0 0 0 0)) + +;;;*** + +;; Local Variables: +;; version-control: never +;; no-byte-compile: t +;; no-update-autoloads: t +;; coding: utf-8 +;; End: +;;; powerline-autoloads.el ends here diff --git a/code/elpa/powerline-20221110.1956/powerline-pkg.el b/code/elpa/powerline-20221110.1956/powerline-pkg.el new file mode 100644 index 0000000..360a559 --- /dev/null +++ b/code/elpa/powerline-20221110.1956/powerline-pkg.el @@ -0,0 +1,12 @@ +(define-package "powerline" "20221110.1956" "Rewrite of Powerline" + '((cl-lib "0.2")) + :commit "c35c35bdf5ce2d992882c1f06f0f078058870d4a" :authors + '(("Donald Ephraim Curtis" . "dcurtis@milkbox.net")) + :maintainer + '("Donald Ephraim Curtis" . "dcurtis@milkbox.net") + :keywords + '("mode-line") + :url "http://github.com/milkypostman/powerline/") +;; Local Variables: +;; no-byte-compile: t +;; End: diff --git a/code/elpa/powerline-20221110.1956/powerline-separators.el b/code/elpa/powerline-20221110.1956/powerline-separators.el new file mode 100644 index 0000000..c1b75b9 --- /dev/null +++ b/code/elpa/powerline-20221110.1956/powerline-separators.el @@ -0,0 +1,656 @@ +;;; powerline-separators.el --- Separators for Powerline + +;; Copyright (C) 2012-2013 Donald Ephraim Curtis +;; Copyright (C) 2013 Jason Milkins +;; Copyright (C) 2012 Nicolas Rougier + +;; This file is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation; either version 3, or (at your option) +;; any later version. + +;; This file is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with this program. If not, see . + +;;; Commentary: +;; +;; Separators for Powerline. +;; Included separators: alternate, arrow, arrow-fade, bar, box, brace, butt, +;; chamfer, contour, curve, rounded, roundstub, slant, wave, zigzag, and nil. +;; + +;;; Code: + +(require 'cl-lib) +(require 'color) +(require 'ring) + +(defvar powerline-image-apple-rgb + (and (eq (window-system) 'ns) + (bound-and-true-p ns-use-srgb-colorspace) + (< 11 + (string-to-number + (save-match-data + (and (string-match "darwin\\([0-9]+\\)" system-configuration) + (match-string-no-properties 1 system-configuration))))) + (< emacs-major-version 28)) + "If non-nil, use Apple RGB colorspace to render images. + +t on macOS 10.7+ and `ns-use-srgb-colorspace' is t, nil otherwise. + +This variable is automatically set, there's no need to modify it. + +Obsolete since Emacs 28.") + +(defun pl/interpolate (color1 color2) + "Interpolate between COLOR1 and COLOR2. + +COLOR1 and COLOR2 must be supplied as hex strings with a leading #." + (let* ((c1 (color-name-to-rgb color1)) + (c2 (color-name-to-rgb color2)) + (red (/ (+ (nth 0 c1) (nth 0 c2)) 2)) + (green (/ (+ (nth 1 c1) (nth 1 c2)) 2)) + (blue (/ (+ (nth 2 c1) (nth 2 c2)) 2))) + (color-rgb-to-hex red green blue))) + +(defun pl/color-xyz-to-apple-rgb (X Y Z) + "Convert CIE X Y Z colors to Apple RGB color space." + (let ((r (+ (* 3.2404542 X) (* -1.5371385 Y) (* -0.4985314 Z))) + (g (+ (* -0.9692660 X) (* 1.8760108 Y) (* 0.0415560 Z))) + (b (+ (* 0.0556434 X) (* -0.2040259 Y) (* 1.0572252 Z)))) + (list (expt r (/ 1.8)) (expt g (/ 1.8)) (expt b (/ 1.8))))) + +(defun pl/color-srgb-to-apple-rgb (red green blue) + "Convert RED GREEN BLUE colors from sRGB color space to Apple RGB. +RED, GREEN and BLUE should be between 0.0 and 1.0, inclusive." + (apply 'pl/color-xyz-to-apple-rgb (color-srgb-to-xyz red green blue))) + +(defun pl/hex-color (color) + "Get the hexadecimal value of COLOR." + (when color + (let ((srgb-color (color-name-to-rgb color))) + (if powerline-image-apple-rgb + (apply 'color-rgb-to-hex (apply 'pl/color-srgb-to-apple-rgb srgb-color)) + (apply 'color-rgb-to-hex srgb-color))))) + +(defun pl/pattern (lst) + "Turn LST into an infinite pattern." + (when lst + (ring-convert-sequence-to-ring lst))) + +(defun pl/pattern-to-string (pattern) + "Convert a PATTERN into a string that can be used in an XPM." + (concat "\"" (mapconcat 'number-to-string pattern "") "\",")) + +(defun pl/reverse-pattern (pattern) + "Reverse each line in PATTERN." + (mapcar 'reverse pattern)) + +(defun pl/row-pattern (fill total &optional fade) + "Return list that has FILL 0s out of TOTAL 1s with FADE 2s to the right." + (unless fade + (setq fade 0)) + (let ((fill (min fill total)) + (fade (min fade (max (- total fill) 0)))) + (nconc (make-list fill 0) + (make-list fade 2) + (make-list (- total fill fade) 1)))) + +(defun pl/pattern-bindings-body (patterns height-exp pattern-height-sym + second-pattern-height-sym) + "Create let-var bindings and a function body from PATTERNS. +The `car' and `cdr' parts of the result can be passed to the +function `pl/wrap-defun' as its `let-vars' and `body' arguments, +respectively. HEIGHT-EXP is an expression calculating the image +height and it should contain a free variable `height'. +PATTERN-HEIGHT-SYM and SECOND-PATTERN-HEIGHT-SYM are symbols used +for let-var binding variables." + (let* ((pattern (pl/pattern (mapcar 'pl/pattern-to-string (car patterns)))) + (header (mapcar 'pl/pattern-to-string (nth 1 patterns))) + (footer (mapcar 'pl/pattern-to-string (nth 2 patterns))) + (second-pattern (pl/pattern (mapcar 'pl/pattern-to-string (nth 3 patterns)))) + (center (mapcar 'pl/pattern-to-string (nth 4 patterns))) + (reserve (+ (length header) (length footer) (length center)))) + (when pattern + (cons `((,pattern-height-sym (max (- ,height-exp ,reserve) 0)) + (,second-pattern-height-sym (/ ,pattern-height-sym 2)) + (,pattern-height-sym ,(if second-pattern `(ceiling ,pattern-height-sym 2) `,pattern-height-sym))) + (list (when header `(apply 'concat ',header)) + `(cl-loop for i to ,pattern-height-sym + concat (ring-ref ',pattern i)) + (when center `(apply 'concat ',center)) + (when second-pattern + `(cl-loop for i to ,second-pattern-height-sym + concat (ring-ref ',second-pattern i))) + (when footer `(apply 'concat ',footer))))))) + +(defun pl/pattern-defun (name dir width &rest patterns) + "Create a powerline function of NAME in DIR with WIDTH for PATTERNS. + +PATTERNS is of the form (PATTERN HEADER FOOTER SECOND-PATTERN CENTER +PATTERN-2X HEADER-2X FOOTER-2X SECOND-PATTERN-2X CENTER-2X). +PATTERN is required, all other components are optional. +The first 5 components are for the standard resolution image. +The remaining ones are for the high resolution image where both +width and height are doubled. If PATTERN-2X is nil or not given, +then the remaining components are ignored and the standard +resolution image with magnification and interpolation will be +used in high resolution environments + +All generated functions generate the form: +HEADER +PATTERN ... +CENTER +SECOND-PATTERN ... +FOOTER + +PATTERN and SECOND-PATTERN repeat infinitely to fill the space +needed to generate a full height XPM. + +PATTERN, HEADER, FOOTER, SECOND-PATTERN, CENTER are of the +form ((COLOR ...) (COLOR ...) ...). + +COLOR can be one of 0, 1, or 2, where 0 is the source color, 1 is +the destination color, and 2 is the interpolated color between 0 +and 1." + (when (eq dir 'right) + (setq patterns (mapcar 'pl/reverse-pattern patterns))) + (let ((bindings-body (pl/pattern-bindings-body patterns + 'height + 'pattern-height + 'second-pattern-height)) + (bindings-body-2x (pl/pattern-bindings-body (nthcdr 5 patterns) + '(* height 2) + 'pattern-height-2x + 'second-pattern-height-2x))) + (pl/wrap-defun name dir width + (append (car bindings-body) (car bindings-body-2x)) + (cdr bindings-body) (cdr bindings-body-2x)))) + +(defun pl/background-color (face) + (face-attribute face + (if (face-attribute face :inverse-video nil 'default) + :foreground + :background) + nil + 'default)) + +(defun pl/wrap-defun (name dir width let-vars body &optional body-2x) + "Generate a powerline function of NAME in DIR with WIDTH using LET-VARS and BODY." + (let* ((src-face (if (eq dir 'left) 'face1 'face2)) + (dst-face (if (eq dir 'left) 'face2 'face1))) + `(defun ,(intern (format "powerline-%s-%s" name (symbol-name dir))) + (face1 face2 &optional height) + (when window-system + (unless height (setq height (pl/separator-height))) + (let* ,(append `((color1 (when ,src-face + (pl/hex-color (pl/background-color ,src-face)))) + (color2 (when ,dst-face + (pl/hex-color (pl/background-color ,dst-face)))) + (colori (when (and color1 color2) (pl/interpolate color1 color2))) + (color1 (or color1 "None")) + (color2 (or color2 "None")) + (colori (or colori "None"))) + let-vars) + (apply 'create-image + ,(append `(concat (format "/* XPM */ static char * %s_%s[] = { \"%s %s 3 1\", \"0 c %s\", \"1 c %s\", \"2 c %s\"," + ,(replace-regexp-in-string "-" "_" name) + (symbol-name ',dir) + ,width + height + color1 + color2 + colori)) + body + '("};")) + 'xpm t + :ascent 'center + :scale 1 + :face (when (and face1 face2) + ,dst-face) + ,(and body-2x + `(and (featurep 'mac) + (list :data-2x + ,(append `(concat (format "/* XPM */ static char * %s_%s_2x[] = { \"%s %s 3 1\", \"0 c %s\", \"1 c %s\", \"2 c %s\"," + ,(replace-regexp-in-string "-" "_" name) + (symbol-name ',dir) + (* ,width 2) + (* height 2) + color1 + color2 + colori)) + body-2x + '("};"))))))))))) + +(defmacro pl/alternate (dir) + "Generate an alternating pattern XPM function for DIR." + (pl/pattern-defun "alternate" dir 4 + '((2 2 1 1) + (0 0 2 2)) + nil nil nil nil + ;; 2x + '((2 2 2 2 1 1 1 1) + (2 2 2 2 1 1 1 1) + (0 0 0 0 2 2 2 2) + (0 0 0 0 2 2 2 2)))) + +(defmacro pl/arrow (dir) + "Generate an arrow XPM function for DIR." + (let ((row-modifier (if (eq dir 'left) 'identity 'reverse))) + (pl/wrap-defun "arrow" dir 'middle-width + '((width (1- (/ height 2))) + (middle-width (1- (ceiling height 2)))) + `((cl-loop for i from 0 to width + concat (pl/pattern-to-string (,row-modifier (pl/row-pattern i middle-width)))) + (when (cl-oddp height) + (pl/pattern-to-string (make-list middle-width 0))) + (cl-loop for i from width downto 0 + concat (pl/pattern-to-string (,row-modifier (pl/row-pattern i middle-width))))) + `((when (cl-evenp height) + (pl/pattern-to-string (make-list (* middle-width 2) 1))) + (cl-loop for i from 0 to (* middle-width 2) + concat (pl/pattern-to-string (,row-modifier (pl/row-pattern i (* middle-width 2))))) + (cl-loop for i from (* middle-width 2) downto 0 + concat (pl/pattern-to-string (,row-modifier (pl/row-pattern i (* middle-width 2))))) + (when (cl-evenp height) + (pl/pattern-to-string (make-list (* middle-width 2) 1))))))) + +(defmacro pl/arrow-fade (dir) + "Generate an arrow-fade XPM function for DIR." + (let* ((row-modifier (if (eq dir 'left) 'identity 'reverse))) + (pl/wrap-defun "arrow-fade" dir 'middle-width + '((width (1- (/ height 2))) + (middle-width (1+ (ceiling height 2)))) + `((cl-loop for i from 0 to width + concat (pl/pattern-to-string (,row-modifier (pl/row-pattern i middle-width 2)))) + (when (cl-oddp height) + (pl/pattern-to-string (,row-modifier (pl/row-pattern (1+ width) middle-width 2)))) + (cl-loop for i from width downto 0 + concat (pl/pattern-to-string (,row-modifier (pl/row-pattern i middle-width 2))))) + `((when (cl-evenp height) + (pl/pattern-to-string (,row-modifier (pl/row-pattern 0 (* middle-width 2) (* 2 2))))) + (cl-loop for i from 0 to (* (- middle-width 2) 2) + concat (pl/pattern-to-string (,row-modifier (pl/row-pattern i (* middle-width 2) (* 2 2))))) + (cl-loop for i from (* (- middle-width 2) 2) downto 0 + concat (pl/pattern-to-string (,row-modifier (pl/row-pattern i (* middle-width 2) (* 2 2))))) + (when (cl-evenp height) + (pl/pattern-to-string (,row-modifier (pl/row-pattern 0 (* middle-width 2) (* 2 2))))))))) + +(defmacro pl/bar (dir) + "Generate a bar XPM function for DIR." + (pl/pattern-defun "bar" dir 2 + '((2 2)))) + +(defmacro pl/box (dir) + "Generate a box XPM function for DIR." + (pl/pattern-defun "box" dir 2 + '((0 0) + (0 0) + (1 1) + (1 1)) + nil nil nil nil + ;; 2x + '((0 0 0 0) + (0 0 0 0) + (0 0 0 0) + (0 0 0 0) + (1 1 1 1) + (1 1 1 1) + (1 1 1 1) + (1 1 1 1)))) + +(defmacro pl/brace (dir) + "Generate a brace XPM function for DIR." + (pl/pattern-defun "brace" dir 4 + '((0 1 1 1)) + '((1 1 1 1) + (2 1 1 1)) + '((2 1 1 1) + (1 1 1 1)) + '((0 1 1 1)) + '((0 2 1 1) + (0 2 1 1) + (0 0 2 1) + (0 0 0 0) + (0 0 2 1) + (0 2 1 1) + (0 2 1 1)) + ;; 2x + '((0 0 1 1 1 1 1 1)) + '((1 1 1 1 1 1 1 1) + (1 1 1 1 1 1 1 1) + (2 1 1 1 1 1 1 1) + (0 2 1 1 1 1 1 1)) + '((0 2 1 1 1 1 1 1) + (2 1 1 1 1 1 1 1) + (1 1 1 1 1 1 1 1) + (1 1 1 1 1 1 1 1)) + '((0 0 1 1 1 1 1 1)) + '((0 0 2 1 1 1 1 1) + (0 0 0 1 1 1 1 1) + (0 0 0 2 1 1 1 1) + (0 0 0 0 1 1 1 1) + (0 0 0 0 2 1 1 1) + (0 0 0 0 0 2 1 1) + (0 0 0 0 0 0 0 2) + (0 0 0 0 0 0 0 2) + (0 0 0 0 0 2 1 1) + (0 0 0 0 2 1 1 1) + (0 0 0 0 1 1 1 1) + (0 0 0 2 1 1 1 1) + (0 0 0 1 1 1 1 1) + (0 0 2 1 1 1 1 1)))) + +(defmacro pl/butt (dir) + "Generate a butt XPM function for DIR." + (pl/pattern-defun "butt" dir 3 + '((0 0 0)) + '((1 1 1) + (0 1 1) + (0 0 1)) + '((0 0 1) + (0 1 1) + (1 1 1)) + nil nil + ;; 2x + '((0 0 0 0 0 0)) + '((1 1 1 1 1 1) + (0 1 1 1 1 1) + (0 0 1 1 1 1) + (0 0 0 1 1 1) + (0 0 0 0 1 1) + (0 0 0 0 0 1)) + '((0 0 0 0 0 1) + (0 0 0 0 1 1) + (0 0 0 1 1 1) + (0 0 1 1 1 1) + (0 1 1 1 1 1) + (1 1 1 1 1 1)))) + +(defmacro pl/chamfer (dir) + "Generate a chamfer XPM function for DIR." + (pl/pattern-defun "chamfer" dir 3 + '((0 0 0)) + '((1 1 1) + (0 1 1) + (0 0 1)) + nil nil nil + ;; 2x + '((0 0 0 0 0 0)) + '((1 1 1 1 1 1) + (0 1 1 1 1 1) + (0 0 1 1 1 1) + (0 0 0 1 1 1) + (0 0 0 0 1 1) + (0 0 0 0 0 1)))) + +(defmacro pl/contour (dir) + "Generate a contour XPM function for DIR." + (pl/pattern-defun "contour" dir 10 + '((0 0 0 0 0 1 1 1 1 1)) + '((1 1 1 1 1 1 1 1 1 1) + (0 2 1 1 1 1 1 1 1 1) + (0 0 2 1 1 1 1 1 1 1) + (0 0 0 2 1 1 1 1 1 1) + (0 0 0 0 1 1 1 1 1 1) + (0 0 0 0 2 1 1 1 1 1)) + '((0 0 0 0 0 2 1 1 1 1) + (0 0 0 0 0 0 1 1 1 1) + (0 0 0 0 0 0 2 1 1 1) + (0 0 0 0 0 0 0 2 1 1) + (0 0 0 0 0 0 0 0 0 0)) + nil nil + ;; 2x + '((0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1)) + '((1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1) + (1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1) + (0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1) + (0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1) + (0 0 0 0 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1) + (0 0 0 0 0 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1) + (0 0 0 0 0 0 2 1 1 1 1 1 1 1 1 1 1 1 1 1) + (0 0 0 0 0 0 0 2 1 1 1 1 1 1 1 1 1 1 1 1) + (0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1) + (0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1) + (0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1) + (0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1)) + '((0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1) + (0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1) + (0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1) + (0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1) + (0 0 0 0 0 0 0 0 0 0 0 0 2 1 1 1 1 1 1 1) + (0 0 0 0 0 0 0 0 0 0 0 0 0 2 1 1 1 1 1 1) + (0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1) + (0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1) + (0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0) + (0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0)))) + +(defmacro pl/curve (dir) + "Generate a curve XPM function for DIR." + (pl/pattern-defun "curve" dir 4 + '((0 0 0 0)) + '((1 1 1 1) + (2 1 1 1) + (0 0 1 1) + (0 0 2 1) + (0 0 0 1) + (0 0 0 2)) + '((0 0 0 2) + (0 0 0 1) + (0 0 2 1) + (0 0 1 1) + (2 1 1 1) + (1 1 1 1)) + nil nil + ;; 2x + '((0 0 0 0 0 0 0 0)) + '((1 1 1 1 1 1 1 1) + (1 1 1 1 1 1 1 1) + (1 1 1 1 1 1 1 1) + (0 0 1 1 1 1 1 1) + (0 0 0 2 1 1 1 1) + (0 0 0 0 2 1 1 1) + (0 0 0 0 0 2 1 1) + (0 0 0 0 0 0 1 1) + (0 0 0 0 0 0 1 1) + (0 0 0 0 0 0 0 1) + (0 0 0 0 0 0 0 1) + (0 0 0 0 0 0 0 1)) + '((0 0 0 0 0 0 0 1) + (0 0 0 0 0 0 0 1) + (0 0 0 0 0 0 0 1) + (0 0 0 0 0 0 1 1) + (0 0 0 0 0 0 1 1) + (0 0 0 0 0 2 1 1) + (0 0 0 0 2 1 1 1) + (0 0 0 2 1 1 1 1) + (0 0 1 1 1 1 1 1) + (1 1 1 1 1 1 1 1) + (1 1 1 1 1 1 1 1) + (1 1 1 1 1 1 1 1)))) + +(defmacro pl/rounded (dir) + "Generate a rounded XPM function for DIR." + (pl/pattern-defun "rounded" dir 6 + '((0 0 0 0 0 0)) + '((2 1 1 1 1 1) + (0 0 2 1 1 1) + (0 0 0 0 1 1) + (0 0 0 0 2 1) + (0 0 0 0 0 1) + (0 0 0 0 0 2)) + nil nil nil + ;; 2x + '((0 0 0 0 0 0 0 0 0 0 0 0)) + '((1 1 1 1 1 1 1 1 1 1 1 1) + (0 0 2 1 1 1 1 1 1 1 1 1) + (0 0 0 0 1 1 1 1 1 1 1 1) + (0 0 0 0 0 0 1 1 1 1 1 1) + (0 0 0 0 0 0 0 2 1 1 1 1) + (0 0 0 0 0 0 0 0 1 1 1 1) + (0 0 0 0 0 0 0 0 0 1 1 1) + (0 0 0 0 0 0 0 0 0 0 1 1) + (0 0 0 0 0 0 0 0 0 0 1 1) + (0 0 0 0 0 0 0 0 0 0 2 1) + (0 0 0 0 0 0 0 0 0 0 0 1) + (0 0 0 0 0 0 0 0 0 0 0 1)))) + +(defmacro pl/roundstub (dir) + "Generate a roundstub XPM function for DIR." + (pl/pattern-defun "roundstub" dir 3 + '((0 0 0)) + '((1 1 1) + (0 0 1) + (0 0 2)) + '((0 0 2) + (0 0 1) + (1 1 1)) + nil nil + ;; 2x + '((0 0 0 0 0 0)) + '((1 1 1 1 1 1) + (2 1 1 1 1 1) + (0 0 0 2 1 1) + (0 0 0 0 1 1) + (0 0 0 0 0 1) + (0 0 0 0 0 1)) + '((0 0 0 0 0 1) + (0 0 0 0 0 1) + (0 0 0 0 1 1) + (0 0 0 2 1 1) + (2 1 1 1 1 1) + (1 1 1 1 1 1)))) + +(defmacro pl/slant (dir) + "Generate a slant XPM function for DIR." + (let* ((row-modifier (if (eq dir 'left) 'identity 'reverse))) + (pl/wrap-defun "slant" dir 'width + '((width (1- (ceiling height 2)))) + `((cl-loop for i from 0 to (1- height) + concat (pl/pattern-to-string (,row-modifier (pl/row-pattern (/ i 2) width))))) + `((cl-loop for i from 0 to (1- (* height 2)) + concat (pl/pattern-to-string (,row-modifier (pl/row-pattern (/ i 2) (* width 2))))))))) + +(defmacro pl/smooth-slant (dir) + "Generate a smoothed slant XPM function for DIR." + (let* ((row-modifier (if (eq dir 'left) 'identity 'reverse))) + (pl/wrap-defun "smooth-slant" dir 'width + '((width (1- (ceiling height 2)))) + `((cl-loop for i from 0 to (1- height) + concat (pl/pattern-to-string + (,row-modifier + (pl/row-pattern (/ i 2) width (cl-mod i 2)))))) + `((cl-loop for i from 0 to (1- (* height 2)) + concat (pl/pattern-to-string + (,row-modifier + (pl/row-pattern (/ i 2) (* width 2) (cl-mod i 2))))))))) + +(defmacro pl/wave (dir) + "Generate a wave XPM function for DIR." + (pl/pattern-defun "wave" dir 11 + '((0 0 0 0 0 0 1 1 1 1 1)) + '((2 1 1 1 1 1 1 1 1 1 1) + (0 0 1 1 1 1 1 1 1 1 1) + (0 0 0 1 1 1 1 1 1 1 1) + (0 0 0 2 1 1 1 1 1 1 1) + (0 0 0 0 1 1 1 1 1 1 1) + (0 0 0 0 2 1 1 1 1 1 1) + (0 0 0 0 0 1 1 1 1 1 1) + (0 0 0 0 0 1 1 1 1 1 1) + (0 0 0 0 0 2 1 1 1 1 1)) + '((0 0 0 0 0 0 2 1 1 1 1) + (0 0 0 0 0 0 0 1 1 1 1) + (0 0 0 0 0 0 0 1 1 1 1) + (0 0 0 0 0 0 0 2 1 1 1) + (0 0 0 0 0 0 0 0 1 1 1) + (0 0 0 0 0 0 0 0 2 1 1) + (0 0 0 0 0 0 0 0 0 0 2)) + nil nil + ;; 2x + '((0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1)) + '((1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1) + (0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1) + (0 0 0 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1) + (0 0 0 0 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1) + (0 0 0 0 0 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1) + (0 0 0 0 0 0 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1) + (0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1) + (0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1) + (0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1) + (0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1) + (0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1) + (0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1) + (0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1) + (0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1) + (0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1) + (0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1) + (0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1) + (0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1)) + '((0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1) + (0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1) + (0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1) + (0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1) + (0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1) + (0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1) + (0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1) + (0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1) + (0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1) + (0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1) + (0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 1 1 1 1 1) + (0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 1 1 1 1) + (0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1) + (0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0)))) + +(defmacro pl/zigzag (dir) + "Generate a zigzag pattern XPM function for DIR." + (pl/pattern-defun "zigzag" dir 3 + '((1 1 1) + (0 1 1) + (0 0 1) + (0 0 0) + (0 0 1) + (0 1 1)) + nil nil nil nil + ;; 2x + '((1 1 1 1 1 1) + (0 1 1 1 1 1) + (0 0 1 1 1 1) + (0 0 0 1 1 1) + (0 0 0 0 1 1) + (0 0 0 0 0 1) + (0 0 0 0 0 0) + (0 0 0 0 0 1) + (0 0 0 0 1 1) + (0 0 0 1 1 1) + (0 0 1 1 1 1) + (0 1 1 1 1 1)))) + +(defmacro pl/nil (dir) + "Generate a XPM function that returns nil for DIR." + `(defun ,(intern (format "powerline-nil-%s" (symbol-name dir))) + (face1 face2 &optional height) + nil)) + +(defmacro pl/utf-8 (dir) + "Generate function that returns raw utf-8 symbols." + (let ((dir-name (symbol-name dir)) + (src-face (if (eq dir 'left) 'face1 'face2)) + (dst-face (if (eq dir 'left) 'face2 'face1))) + `(defun ,(intern (format "powerline-utf-8-%s" dir-name)) + (face1 face2 &optional height) + (powerline-raw + (char-to-string ,(intern (format "powerline-utf-8-separator-%s" + dir-name))) + (list :foreground (pl/background-color ,src-face) + :background (pl/background-color ,dst-face) + :inverse-video nil))))) + + +(provide 'powerline-separators) + +;;; powerline-separators.el ends here diff --git a/code/elpa/powerline-20221110.1956/powerline-themes.el b/code/elpa/powerline-20221110.1956/powerline-themes.el new file mode 100644 index 0000000..20b43e3 --- /dev/null +++ b/code/elpa/powerline-20221110.1956/powerline-themes.el @@ -0,0 +1,294 @@ +;;; powerline-themes.el --- Themes for Powerline + +;; Copyright (C) 2012-2013 Donald Ephraim Curtis +;; Copyright (C) 2013 Jason Milkins +;; Copyright (C) 2012 Nicolas Rougier + +;; This file is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation; either version 3, or (at your option) +;; any later version. + +;; This file is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with this program. If not, see . + +;;; Commentary: +;; +;; Themes for Powerline. +;; Included themes: default, center, center-evil, vim, and nano. +;; + +;;; Code: + +(defcustom powerline-display-buffer-size t + "When non-nil, display the buffer size." + :group 'powerline + :type 'boolean) + +(defcustom powerline-display-mule-info t + "When non-nil, display the mule info." + :group 'powerline + :type 'boolean) + +(defcustom powerline-display-hud t + "When non-nil, display the hud." + :group 'powerline + :type 'boolean) + +;;;###autoload +(defun powerline-default-theme () + "Setup the default mode-line." + (interactive) + (setq-default mode-line-format + '("%e" + (:eval + (let* ((active (powerline-selected-window-active)) + (mode-line-buffer-id (if active 'mode-line-buffer-id 'mode-line-buffer-id-inactive)) + (mode-line (if active 'mode-line 'mode-line-inactive)) + (face0 (if active 'powerline-active0 'powerline-inactive0)) + (face1 (if active 'powerline-active1 'powerline-inactive1)) + (face2 (if active 'powerline-active2 'powerline-inactive2)) + (separator-left (intern (format "powerline-%s-%s" + (powerline-current-separator) + (car powerline-default-separator-dir)))) + (separator-right (intern (format "powerline-%s-%s" + (powerline-current-separator) + (cdr powerline-default-separator-dir)))) + (lhs (list (powerline-raw "%*" face0 'l) + (when powerline-display-buffer-size + (powerline-buffer-size face0 'l)) + (when powerline-display-mule-info + (powerline-raw mode-line-mule-info face0 'l)) + (powerline-buffer-id `(mode-line-buffer-id ,face0) 'l) + (when (and (boundp 'which-func-mode) which-func-mode) + (powerline-raw which-func-format face0 'l)) + (powerline-raw " " face0) + (funcall separator-left face0 face1) + (when (and (boundp 'erc-track-minor-mode) erc-track-minor-mode) + (powerline-raw erc-modified-channels-object face1 'l)) + (powerline-major-mode face1 'l) + (powerline-process face1) + (powerline-minor-modes face1 'l) + (powerline-narrow face1 'l) + (powerline-raw " " face1) + (funcall separator-left face1 face2) + (powerline-vc face2 'r) + (when (bound-and-true-p nyan-mode) + (powerline-raw (list (nyan-create)) face2 'l)))) + (rhs (list (powerline-raw global-mode-string face2 'r) + (funcall separator-right face2 face1) + (unless window-system + (powerline-raw (char-to-string #xe0a1) face1 'l)) + (powerline-raw "%4l" face1 'l) + (powerline-raw ":" face1 'l) + (powerline-raw "%3c" face1 'r) + (funcall separator-right face1 face0) + (powerline-raw " " face0) + (powerline-raw "%6p" face0 'r) + (when powerline-display-hud + (powerline-hud face0 face2)) + (powerline-fill face0 0) + ))) + (concat (powerline-render lhs) + (powerline-fill face2 (powerline-width rhs)) + (powerline-render rhs))))))) + +;;;###autoload +(defun powerline-center-theme () + "Setup a mode-line with major and minor modes centered." + (interactive) + (setq-default mode-line-format + '("%e" + (:eval + (let* ((active (powerline-selected-window-active)) + (mode-line-buffer-id (if active 'mode-line-buffer-id 'mode-line-buffer-id-inactive)) + (mode-line (if active 'mode-line 'mode-line-inactive)) + (face0 (if active 'powerline-active0 'powerline-inactive0)) + (face1 (if active 'powerline-active1 'powerline-inactive1)) + (face2 (if active 'powerline-active2 'powerline-inactive2)) + (separator-left (intern (format "powerline-%s-%s" + (powerline-current-separator) + (car powerline-default-separator-dir)))) + (separator-right (intern (format "powerline-%s-%s" + (powerline-current-separator) + (cdr powerline-default-separator-dir)))) + (lhs (list (powerline-raw "%*" face0 'l) + (when powerline-display-buffer-size + (powerline-buffer-size face0 'l)) + (powerline-buffer-id `(mode-line-buffer-id ,face0) 'l) + (powerline-raw " " face0) + (funcall separator-left face0 face1) + (powerline-narrow face1 'l) + (powerline-vc face1))) + (rhs (list (powerline-raw global-mode-string face1 'r) + (powerline-raw "%4l" face1 'r) + (powerline-raw ":" face1) + (powerline-raw "%3c" face1 'r) + (funcall separator-right face1 face0) + (powerline-raw " " face0) + (powerline-raw "%6p" face0 'r) + (when powerline-display-hud + (powerline-hud face2 face1)) + (powerline-fill face0 0))) + (center (list (powerline-raw " " face1) + (funcall separator-left face1 face2) + (when (and (boundp 'erc-track-minor-mode) erc-track-minor-mode) + (powerline-raw erc-modified-channels-object face2 'l)) + (powerline-major-mode face2 'l) + (powerline-process face2) + (powerline-raw " :" face2) + (powerline-minor-modes face2 'l) + (powerline-raw " " face2) + (funcall separator-right face2 face1)))) + (concat (powerline-render lhs) + (powerline-fill-center face1 (/ (powerline-width center) 2.0)) + (powerline-render center) + (powerline-fill face1 (powerline-width rhs)) + (powerline-render rhs))))))) + +(defun powerline-center-evil-theme () + "Setup a mode-line with major, evil, and minor modes centered." + (interactive) + (setq-default mode-line-format + '("%e" + (:eval + (let* ((active (powerline-selected-window-active)) + (mode-line-buffer-id (if active 'mode-line-buffer-id 'mode-line-buffer-id-inactive)) + (mode-line (if active 'mode-line 'mode-line-inactive)) + (face0 (if active 'powerline-active0 'powerline-inactive0)) + (face1 (if active 'powerline-active1 'powerline-inactive1)) + (face2 (if active 'powerline-active2 'powerline-inactive2)) + (separator-left (intern (format "powerline-%s-%s" + (powerline-current-separator) + (car powerline-default-separator-dir)))) + (separator-right (intern (format "powerline-%s-%s" + (powerline-current-separator) + (cdr powerline-default-separator-dir)))) + (lhs (list (powerline-raw "%*" face0 'l) + (when powerline-display-buffer-size + (powerline-buffer-size face0 'l)) + (powerline-buffer-id `(mode-line-buffer-id ,face0) 'l) + (powerline-raw " " face0) + (funcall separator-left face0 face1) + (powerline-narrow face1 'l) + (powerline-vc face1))) + (rhs (list (powerline-raw global-mode-string face1 'r) + (powerline-raw "%4l" face1 'r) + (powerline-raw ":" face1) + (powerline-raw "%3c" face1 'r) + (funcall separator-right face1 face0) + (powerline-raw " " face0) + (powerline-raw "%6p" face0 'r) + (when powerline-display-hud + (powerline-hud face2 face1)))) + (center (append (list (powerline-raw " " face1) + (funcall separator-left face1 face2) + (when (and (boundp 'erc-track-minor-mode) erc-track-minor-mode) + (powerline-raw erc-modified-channels-object face2 'l)) + (powerline-major-mode face2 'l) + (powerline-process face2) + (powerline-raw " " face2)) + (if (split-string (format-mode-line minor-mode-alist)) + (append (if evil-mode + (list (funcall separator-right face2 face1) + (powerline-raw evil-mode-line-tag face1 'l) + (powerline-raw " " face1) + (funcall separator-left face1 face2))) + (list (powerline-minor-modes face2 'l) + (powerline-raw " " face2) + (funcall separator-right face2 face1))) + (list (powerline-raw evil-mode-line-tag face2) + (funcall separator-right face2 face1)))))) + (concat (powerline-render lhs) + (powerline-fill-center face1 (/ (powerline-width center) 2.0)) + (powerline-render center) + (powerline-fill face1 (powerline-width rhs)) + (powerline-render rhs))))))) + +;;;###autoload +(defun powerline-vim-theme () + "Setup a Vim-like mode-line." + (interactive) + (setq-default mode-line-format + '("%e" + (:eval + (let* ((active (powerline-selected-window-active)) + (mode-line (if active 'mode-line 'mode-line-inactive)) + (face0 (if active 'powerline-active0 'powerline-inactive0)) + (face1 (if active 'powerline-active1 'powerline-inactive1)) + (face2 (if active 'powerline-active2 'powerline-inactive2)) + (separator-left (intern (format "powerline-%s-%s" + (powerline-current-separator) + (car powerline-default-separator-dir)))) + (separator-right (intern (format "powerline-%s-%s" + (powerline-current-separator) + (cdr powerline-default-separator-dir)))) + (lhs (list (powerline-buffer-id `(mode-line-buffer-id ,face0) 'l) + (powerline-raw "[" face0 'l) + (powerline-major-mode face0) + (powerline-process face0) + (powerline-raw "]" face0) + (when (buffer-modified-p) + (powerline-raw "[+]" face0)) + (when buffer-read-only + (powerline-raw "[RO]" face0)) + (powerline-raw "[%z]" face0) + ;; (powerline-raw (concat "[" (mode-line-eol-desc) "]") face0) + (when (and (boundp 'which-func-mode) which-func-mode) + (powerline-raw which-func-format nil 'l)) + (when (and (boundp 'erc-track-minor-mode) erc-track-minor-mode) + (powerline-raw erc-modified-channels-object face1 'l)) + (powerline-raw "[" face0 'l) + (powerline-minor-modes face0) + (powerline-raw "%n" face0) + (powerline-raw "]" face0) + (when (and vc-mode buffer-file-name) + (let ((backend (vc-backend buffer-file-name))) + (when backend + (concat (powerline-raw "[" face0 'l) + (powerline-raw (format "%s / %s" backend (vc-working-revision buffer-file-name backend)) face0) + (powerline-raw "]" face0))))))) + (rhs (list (powerline-raw '(10 "%i") face0) + (powerline-raw global-mode-string face0 'r) + (powerline-raw "%l," face0 'l) + (powerline-raw (format-mode-line '(10 "%c")) face0) + (powerline-raw (replace-regexp-in-string "%" "%%" (format-mode-line '(-3 "%p"))) face0 'r) + (powerline-fill face0 0)))) + (concat (powerline-render lhs) + (powerline-fill face0 (powerline-width rhs)) + (powerline-render rhs))))))) + +;;;###autoload +(defun powerline-nano-theme () + "Setup a nano-like mode-line." + (interactive) + (setq-default mode-line-format + '("%e" + (:eval + (let* ((active (powerline-selected-window-active)) + (face0 (if active 'powerline-active0 'powerline-inactive0)) + (lhs (list (powerline-raw (concat "GNU Emacs " + (number-to-string + emacs-major-version) + "." + (number-to-string + emacs-minor-version)) + face0 'l))) + (rhs (list (if (buffer-modified-p) (powerline-raw "Modified" face0 'r)) + (powerline-fill face0 0))) + (center (list (powerline-raw "%b" face0)))) + (concat (powerline-render lhs) + (powerline-fill-center face0 (/ (powerline-width center) 2.0)) + (powerline-render center) + (powerline-fill face0 (powerline-width rhs)) + (powerline-render rhs))))))) + + +(provide 'powerline-themes) + +;;; powerline-themes.el ends here diff --git a/code/elpa/powerline-20221110.1956/powerline.el b/code/elpa/powerline-20221110.1956/powerline.el new file mode 100644 index 0000000..23f5bdf --- /dev/null +++ b/code/elpa/powerline-20221110.1956/powerline.el @@ -0,0 +1,630 @@ +;;; powerline.el --- Rewrite of Powerline + +;; Copyright (C) 2012-2013 Donald Ephraim Curtis +;; Copyright (C) 2013 Jason Milkins +;; Copyright (C) 2012 Nicolas Rougier + +;; Author: Donald Ephraim Curtis +;; URL: http://github.com/milkypostman/powerline/ +;; Version: 2.5 +;; Keywords: mode-line +;; Package-Requires: ((cl-lib "0.2")) + +;; This file is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation; either version 3, or (at your option) +;; any later version. + +;; This file is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with this program. If not, see . + +;;; Commentary: +;; +;; Powerline is a library for customizing the mode-line that is based on the Vim +;; Powerline. A collection of predefined themes comes with the package. +;; + +;;; Code: + +(eval-and-compile (require 'powerline-themes)) +(eval-and-compile (require 'powerline-separators)) + +(require 'cl-lib) + +(defgroup powerline nil + "Powerline, a prettier mode line." + :group 'mode-line) + +(defface powerline-active0 '((t (:inherit mode-line))) + "Powerline face 0." + :group 'powerline) + +(defface powerline-active1 '((t (:background "grey17" :foreground "white" :inherit mode-line))) + "Powerline face 1." + :group 'powerline) + +(defface powerline-active2 '((t (:background "grey40" :foreground "white" :inherit mode-line))) + "Powerline face 2." + :group 'powerline) + +(defface powerline-inactive0 + '((t (:inherit mode-line-inactive))) + "Powerline face 0." + :group 'powerline) + +(defface powerline-inactive1 + '((t (:background "grey11" :inherit mode-line-inactive))) + "Powerline face 1." + :group 'powerline) + +(defface powerline-inactive2 + '((t (:background "grey20" :inherit mode-line-inactive))) + "Powerline face 2." + :group 'powerline) + +(defface mode-line-buffer-id-inactive + '((t (:inherit mode-line-buffer-id))) + "Powerline mode-line face" + :group 'powerline) + +(defcustom powerline-default-separator 'arrow + "The separator to use for the default theme. + +Valid Values: alternate, arrow, arrow-fade, bar, box, brace, +butt, chamfer, contour, curve, rounded, roundstub, wave, zigzag, +slant, utf-8." + :group 'powerline + :type '(choice (const alternate) + (const arrow) + (const arrow-fade) + (const bar) + (const box) + (const brace) + (const butt) + (const chamfer) + (const contour) + (const curve) + (const rounded) + (const roundstub) + (const slant) + (const smooth-slant) + (const wave) + (const zigzag) + (const utf-8) + (const nil))) + +(defcustom powerline-utf-8-separator-left #xe0b0 + "The unicode character number for the left facing separator" + :group 'powerline + :type '(choice integer (const nil))) + +(defcustom powerline-utf-8-separator-right #xe0b2 + "The unicode character number for the right facing separator" + :group 'powerline + :type '(choice integer (const nil))) + +(defcustom powerline-default-separator-dir '(left . right) + "The separator direction to use for the default theme. + +CONS of the form (DIR . DIR) denoting the lean of the +separators for the left and right side of the powerline. + +DIR must be one of: left, right" + :group 'powerline + :type '(cons (choice :tag "Left Hand Side" (const left) (const right)) + (choice :tag "Right Hand Side" (const left) (const right)))) + +(defcustom powerline-height nil + "Override the mode-line height." + :group 'powerline + :type '(choice integer (const nil))) + +(defcustom powerline-text-scale-factor nil + "Scale of mode-line font size to default text size. + +Smaller mode-line fonts will be a float value less that 1. +Larger mode-line fonts require a float value greater than 1. + +This is needed to make sure that text is properly aligned." + :group 'powerline + :type '(choice float integer (const nil))) + +(defcustom powerline-buffer-size-suffix t + "Display the buffer size suffix." + :group 'powerline + :type 'boolean) + +(defcustom powerline-gui-use-vcs-glyph nil + "Display a unicode character to represent a version control system. +Not always supported in GUI." + :group 'powerline + :type 'boolean) + +(defcustom powerline-narrowed-indicator "Narrow" + "A string to display in the mode-line when the buffer is narrowed." + :group 'powerline + :type 'string) + +(defun pl/create-or-get-cache () + "Return a frame-local hash table that acts as a memoization cache for powerline. +Create one if the frame doesn't have one yet." + (let ((table (frame-parameter nil 'powerline-cache))) + (if (hash-table-p table) table (pl/reset-cache)))) + +(defun pl/reset-cache () + "Reset and return the frame-local hash table used for a memoization cache." + (let ((table (make-hash-table :test 'equal))) + ;; Store it as a frame-local variable + (modify-frame-parameters nil `((powerline-cache . ,table))) + table)) + +(defun powerline-current-separator () + "Get the current default separator. Always returns utf-8 in non-gui mode." + (if window-system + powerline-default-separator + 'utf-8)) + +;; +;; the frame-local powerline cache causes problems if included in a saved desktop, +;; so delete it before the desktop is saved. +;; +;; see https://github.com/milkypostman/powerline/issues/58 +;; +;; It is better to put the following code into your init file for Emacs 24.4 or later. +;; (require 'frameset) +;; (push '(powerline-cache . :never) frameset-filter-alist) +;; +(defun powerline-delete-cache (&optional frame) + "Set the FRAME cache to nil." + (set-frame-parameter frame 'powerline-cache nil)) + +(defun powerline-desktop-save-delete-cache () + "Set all caches to nil. +This is not done if `frameset-filter-alist' has :never for powerline-cache." + (unless (and (boundp 'frameset-filter-alist) + (eq (cdr (assq 'powerline-cache frameset-filter-alist)) + :never)) + (dolist (fr (frame-list)) (powerline-delete-cache fr)))) + +(add-hook 'desktop-save-hook 'powerline-desktop-save-delete-cache) + +;; from memoize.el @ http://nullprogram.com/blog/2010/07/26/ +(defun pl/memoize (func) + "Memoize FUNC. +If argument is a symbol then install the memoized function over +the original function. Use frame-local memoization." + (cl-typecase func + (symbol (fset func (pl/memoize-wrap-frame-local (symbol-function func))) func) + (function (pl/memoize-wrap-frame-local func)))) + +(defun pl/memoize-wrap-frame-local (func) + "Return the memoized version of FUNC. +The memoization cache is frame-local." + (let ((funcid (cl-gensym))) + `(lambda (&rest args) + ,(concat (documentation func) (format "\n(memoized function %s)" funcid)) + (let* ((cache (pl/create-or-get-cache)) + (key (cons ',funcid args)) + (val (gethash key cache))) + (if val + val + (puthash key (apply ,func args) cache)))))) + +(defun pl/separator-height () + "Get default height for rendering separators." + (or powerline-height (frame-char-height))) + +(defun powerline-reset () + "Reset memoized functions." + (interactive) + (pl/memoize (pl/alternate left)) + (pl/memoize (pl/alternate right)) + (pl/memoize (pl/arrow left)) + (pl/memoize (pl/arrow right)) + (pl/memoize (pl/arrow-fade left)) + (pl/memoize (pl/arrow-fade right)) + (pl/memoize (pl/bar left)) + (pl/memoize (pl/bar right)) + (pl/memoize (pl/box left)) + (pl/memoize (pl/box right)) + (pl/memoize (pl/brace left)) + (pl/memoize (pl/brace right)) + (pl/memoize (pl/butt left)) + (pl/memoize (pl/butt right)) + (pl/memoize (pl/chamfer left)) + (pl/memoize (pl/chamfer right)) + (pl/memoize (pl/contour left)) + (pl/memoize (pl/contour right)) + (pl/memoize (pl/curve left)) + (pl/memoize (pl/curve right)) + (pl/memoize (pl/rounded left)) + (pl/memoize (pl/rounded right)) + (pl/memoize (pl/roundstub left)) + (pl/memoize (pl/roundstub right)) + (pl/memoize (pl/slant left)) + (pl/memoize (pl/slant right)) + (pl/memoize (pl/smooth-slant left)) + (pl/memoize (pl/smooth-slant right)) + (pl/memoize (pl/wave left)) + (pl/memoize (pl/wave right)) + (pl/memoize (pl/zigzag left)) + (pl/memoize (pl/zigzag right)) + (pl/memoize (pl/nil left)) + (pl/memoize (pl/nil right)) + (pl/utf-8 left) + (pl/utf-8 right) + (pl/reset-cache)) + +(powerline-reset) + +(defun pl/make-xpm (name color1 color2 data) + "Return an XPM image with NAME using COLOR1 and COLOR2 bits specified in DATA. +COLOR1 signifies enabled, and COLOR2 signifies disabled." + (when window-system + (create-image + (concat + (format "/* XPM */ +static char * %s[] = { +\"%i %i 2 1\", +\". c %s\", +\" c %s\", +" + (downcase (replace-regexp-in-string " " "_" name)) + (length (car data)) + (length data) + (or (pl/hex-color color1) "None") + (or (pl/hex-color color2) "None")) + (let ((len (length data)) + (idx 0)) + (apply 'concat + (mapcar #'(lambda (dl) + (setq idx (+ idx 1)) + (concat + "\"" + (concat + (mapcar #'(lambda (d) + (if (eq d 0) + (string-to-char " ") + (string-to-char "."))) + dl)) + (if (eq idx len) + "\"};" + "\",\n"))) + data)))) + 'xpm t :scale 1 :ascent 'center))) + +(defun pl/percent-xpm + (height pmax pmin winend winstart width color1 color2) + "Generate percentage xpm of HEIGHT for PMAX to PMIN given WINEND and WINSTART. +Use WIDTH and COLOR1 and COLOR2." + (let* ((height- (1- height)) + (fillstart (round (* height- (/ (float winstart) (float pmax))))) + (fillend (round (* height- (/ (float winend) (float pmax))))) + (data nil) + (i 0)) + (while (< i height) + (setq data (cons + (if (and (<= fillstart i) + (<= i fillend)) + (append (make-list width 1)) + (append (make-list width 0))) + data)) + (setq i (+ i 1))) + (pl/make-xpm "percent" color1 color2 (reverse data)))) + +(pl/memoize 'pl/percent-xpm) + +;;;###autoload +(defun powerline-hud (face1 face2 &optional width) + "Return XPM of relative buffer location using FACE1 and FACE2 of optional WIDTH." + (unless width (setq width 2)) + (let ((color1 (if face1 (face-background face1) "None")) + (color2 (if face2 (face-background face2) "None")) + (height (or powerline-height (frame-char-height))) + pmax + pmin + (ws (window-start)) + (we (window-end))) + (save-restriction + (widen) + (setq pmax (point-max)) + (setq pmin (point-min))) + (pl/percent-xpm height pmax pmin we ws + (* (frame-char-width) width) color1 color2))) + +;;;###autoload +(defun powerline-mouse (click-group click-type string) + "Return mouse handler for CLICK-GROUP given CLICK-TYPE and STRING." + (cond ((eq click-group 'minor) + (cond ((eq click-type 'menu) + `(lambda (event) + (interactive "@e") + (minor-mode-menu-from-indicator ,string))) + ((eq click-type 'help) + `(lambda (event) + (interactive "@e") + (describe-minor-mode-from-indicator ,string))) + (t + `(lambda (event) + (interactive "@e") + nil)))) + (t + `(lambda (event) + (interactive "@e") + nil)))) + +;;;###autoload +(defun powerline-concat (&rest strings) + "Concatonate STRINGS and pad sides by spaces." + (concat + " " + (mapconcat 'identity (delq nil strings) " ") + " ")) + +;;;###autoload +(defmacro defpowerline (name body) + "Create function NAME by wrapping BODY with powerline padding an propetization." + `(defun ,name + (&optional face pad) + (powerline-raw ,body face pad))) + +(defun pl/property-substrings (str prop) + "Return a list of substrings of STR when PROP change." + (let ((beg 0) (end 0) + (len (length str)) + (out)) + (while (< end (length str)) + (setq end (or (next-single-property-change beg prop str) len)) + (setq out (append out (list (substring str beg (setq beg end)))))) + out)) + +(defun pl/assure-list (item) + "Assure that ITEM is a list." + (if (listp item) + item + (list item))) + +(defun pl/add-text-property (str prop val) + (mapconcat + (lambda (mm) + (let ((cur (pl/assure-list (get-text-property 0 'face mm)))) + (propertize mm 'face (append cur (list val))))) + (pl/property-substrings str prop) + "")) + +;;;###autoload +(defun powerline-raw (str &optional face pad) + "Render STR as mode-line data using FACE and optionally PAD import. +PAD can be left (`l') or right (`r')." + (when str + (let* ((rendered-str (format-mode-line str)) + (padded-str (concat + (when (and (> (length rendered-str) 0) (eq pad 'l)) " ") + (if (listp str) rendered-str str) + (when (and (> (length rendered-str) 0) (eq pad 'r)) " ")))) + + (if face + (pl/add-text-property padded-str 'face face) + padded-str)))) + +;;;###autoload +(defun powerline-fill (face reserve) + "Return empty space using FACE and leaving RESERVE space on the right." + (unless reserve + (setq reserve 20)) + (when powerline-text-scale-factor + (setq reserve (* powerline-text-scale-factor reserve))) + (when (and window-system (eq 'right (get-scroll-bar-mode))) + (setq reserve (- reserve 3))) + (propertize " " + 'display `((space :align-to (- (+ right right-fringe right-margin) ,reserve))) + 'face face)) + +(defun powerline-fill-center (face reserve) + "Return empty space using FACE to center of remaining space. +Leave RESERVE space on the right." + (unless reserve + (setq reserve 20)) + (when powerline-text-scale-factor + (setq reserve (* powerline-text-scale-factor reserve))) + (propertize " " + 'display `((space :align-to (- (+ center (.5 . right-margin)) ,reserve + (.5 . left-margin)))) + 'face face)) + +;;;###autoload (autoload 'powerline-major-mode "powerline") +(defpowerline powerline-major-mode + (propertize (format-mode-line mode-name) + 'mouse-face 'mode-line-highlight + 'help-echo "Major mode\n\ mouse-1: Display major mode menu\n\ mouse-2: Show help for major mode\n\ mouse-3: Toggle minor modes" + 'local-map (let ((map (make-sparse-keymap))) + (define-key map [mode-line down-mouse-1] + `(menu-item ,(purecopy "Menu Bar") ignore + :filter (lambda (_) (mouse-menu-major-mode-map)))) + (define-key map [mode-line mouse-2] 'describe-mode) + (define-key map [mode-line down-mouse-3] mode-line-mode-menu) + map))) + +;;;###autoload (autoload 'powerline-minor-modes "powerline") +(defpowerline powerline-minor-modes + (mapconcat (lambda (mm) + (propertize mm + 'mouse-face 'mode-line-highlight + 'help-echo "Minor mode\n mouse-1: Display minor mode menu\n mouse-2: Show help for minor mode\n mouse-3: Toggle minor modes" + 'local-map (let ((map (make-sparse-keymap))) + (define-key map + [mode-line down-mouse-1] + (powerline-mouse 'minor 'menu mm)) + (define-key map + [mode-line mouse-2] + (powerline-mouse 'minor 'help mm)) + (define-key map + [mode-line down-mouse-3] + (powerline-mouse 'minor 'menu mm)) + (define-key map + [header-line down-mouse-3] + (powerline-mouse 'minor 'menu mm)) + map))) + (split-string (format-mode-line minor-mode-alist)) + (propertize " " 'face face))) + +;;;###autoload (autoload 'powerline-narrow "powerline") +(defpowerline powerline-narrow + (when ;; (buffer-narrowed-p) introduced in Emacs 24.3. + (/= (- (point-max) (point-min)) (buffer-size)) + (propertize powerline-narrowed-indicator + 'mouse-face 'mode-line-highlight + 'help-echo "mouse-1: Remove narrowing from the current buffer" + 'local-map (make-mode-line-mouse-map + 'mouse-1 'mode-line-widen)))) + +;;;###autoload (autoload 'powerline-vc "powerline") +(defpowerline powerline-vc + (when (and (buffer-file-name (current-buffer)) vc-mode) + (if (and window-system (not powerline-gui-use-vcs-glyph)) + (format-mode-line '(vc-mode vc-mode)) + (format " %s%s" + (char-to-string #xe0a0) + (format-mode-line '(vc-mode vc-mode)))))) + +;;;###autoload (autoload 'powerline-encoding "powerline") +(defpowerline powerline-encoding + (let ((buf-coding (format "%s" buffer-file-coding-system))) + (if (string-match "\\(dos\\|unix\\|mac\\)" buf-coding) + (match-string 1 buf-coding) + buf-coding))) + + +;;;###autoload (autoload 'powerline-buffer-size "powerline") +(defpowerline powerline-buffer-size + (propertize + (if powerline-buffer-size-suffix + "%I" + "%i") + 'mouse-face 'mode-line-highlight + 'local-map (make-mode-line-mouse-map + 'mouse-1 (lambda () (interactive) + (setq powerline-buffer-size-suffix + (not powerline-buffer-size-suffix)) + (force-mode-line-update))))) + +;;;###autoload (autoload 'powerline-buffer-id "powerline") +(defun powerline-buffer-id (&optional face pad) + (powerline-raw + '(" " (:propertize + mode-line-buffer-identification + 'face face + 'mouse-face 'mode-line-highlight + 'help-echo "Buffer name\n\ mouse-1: Previous buffer\n\ mouse-3: Next buffer" + 'local-map (let ((map (make-sparse-keymap))) + (define-key map [mode-line mouse-1] 'mode-line-previous-buffer) + (define-key map [mode-line mouse-3] 'mode-line-next-buffer) + map))) + face pad)) + +;;;###autoload (autoload 'powerline-process "powerline") +(defpowerline powerline-process + (cond + ((symbolp mode-line-process) (symbol-value mode-line-process)) + ((listp mode-line-process) (format-mode-line mode-line-process)) + (t mode-line-process))) + +(defvar pl/default-mode-line mode-line-format) + +(defvar pl/minibuffer-selected-window-list '()) + +(defun pl/minibuffer-selected-window () + "Return the selected window when entereing the minibuffer." + (when pl/minibuffer-selected-window-list + (car pl/minibuffer-selected-window-list))) + +(defun pl/minibuffer-setup () + "Save the `minibuffer-selected-window' to `pl/minibuffer-selected-window'." + (push (minibuffer-selected-window) pl/minibuffer-selected-window-list)) + +(add-hook 'minibuffer-setup-hook 'pl/minibuffer-setup) + +(defun pl/minibuffer-exit () + "Set `pl/minibuffer-selected-window' to nil." + (pop pl/minibuffer-selected-window-list)) + +(add-hook 'minibuffer-exit-hook 'pl/minibuffer-exit) + +(defvar powerline-selected-window (frame-selected-window) + "Selected window.") + +(defun powerline-set-selected-window () + "Set the variable `powerline-selected-window' appropriately." + (when (not (minibuffer-window-active-p (frame-selected-window))) + (setq powerline-selected-window (frame-selected-window)) + (force-mode-line-update))) + +(defun powerline-unset-selected-window () + "Unset the variable `powerline-selected-window' and update the mode line." + (setq powerline-selected-window nil) + (force-mode-line-update)) + +(add-hook 'window-configuration-change-hook 'powerline-set-selected-window) + +;; Watch focus changes +(if (boundp 'after-focus-change-function) + (add-function :after after-focus-change-function + (lambda () + (if (frame-focus-state) + (powerline-set-selected-window) + (powerline-unset-selected-window)))) + (with-no-warnings + (add-hook 'focus-in-hook 'powerline-set-selected-window) + (add-hook 'focus-out-hook 'powerline-unset-selected-window))) + +;; Executes after the window manager requests that the user's events +;; be directed to a different frame. +(defadvice handle-switch-frame (after powerline-handle-switch-frame activate) + "Call `powerline-set-selected-window'." + (powerline-set-selected-window)) + +(add-hook 'buffer-list-update-hook #'powerline-set-selected-window) + +;;;###autoload (autoload 'powerline-selected-window-active "powerline") +(defun powerline-selected-window-active () + "Return whether the current window is active." + (eq powerline-selected-window (selected-window))) + +(defun powerline-revert () + "Revert to the default Emacs mode-line." + (interactive) + (setq-default mode-line-format pl/default-mode-line)) + +(defun pl/render (item) + "Render a powerline ITEM." + (cond + ((and (listp item) (eq 'image (car item))) + (propertize " " 'display item + 'face (plist-get (cdr item) :face))) + (item item))) + +(defun powerline-render (values) + "Render a list of powerline VALUES." + (mapconcat 'pl/render values "")) + +(defun powerline-width (values) + "Get the length of VALUES." + (if values + (let ((val (car values))) + (+ (cond + ((stringp val) (string-width (format-mode-line val))) + ((and (listp val) (eq 'image (car val))) + (car (image-size val))) + (t 0)) + (powerline-width (cdr values)))) + 0)) + + +(provide 'powerline) + +;;; powerline.el ends here diff --git a/code/init.el b/code/init.el index e980867..70c235d 100644 --- a/code/init.el +++ b/code/init.el @@ -63,7 +63,7 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; additional packages (add-to-list 'package-selected-packages - '(zoom auctex-latexmk auctex json-mode python-mode powershell rust-mode origami go-mode yaml-mode dockerfile-mode lua-mode) + '(centaur-tabs auctex-latexmk auctex json-mode python-mode powershell rust-mode origami go-mode yaml-mode dockerfile-mode lua-mode) ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -76,6 +76,27 @@ ; activate helm after its fully configured (may be configured beyond global defaults in other profiles so we have to activate locally) (helm-mode 1) +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; tab line via centaur tabs +(require 'centaur-tabs) +(setq centaur-tabs-set-bar 'under) +(setq centaur-tabs-set-close-button nil) +(setq centaur-tabs-set-modified-marker t) +(setq centaur-tabs-set-icons t) +(setq centaur-tabs-plain-icons t) +(setq centaur-tabs-cycle-scope 'tabs) +(setq centaur-tabs-show-new-tab-button nil) +(add-hook 'dired-mode-hook 'centaur-tabs-local-mode) +(add-hook 'org-agenda-mode 'centaur-tabs-local-mode) +(global-set-key (kbd "C-c t i") 'centaur-tabs-backward) +(global-set-key (kbd "C-c t ") 'centaur-tabs-backward) +(global-set-key (kbd "C-c t e") 'centaur-tabs-forward) +(global-set-key (kbd "C-c t ") 'centaur-tabs-forward) +(global-set-key (kbd "C-c t y") 'centaur-tabs-local-mode) +(global-set-key (kbd "C-c t ") 'centaur-tabs-local-mode) +(global-set-key (kbd "C-c t ") 'centaur-tabs-local-mode) +(centaur-tabs-mode t) + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; programming ; code folding @@ -140,8 +161,7 @@ ;; Your init file should contain only one such instance. ;; If there is more than one, they won't work right. '(custom-safe-themes - '("dde643b0efb339c0de5645a2bc2e8b4176976d5298065b8e6ca45bc4ddf188b7" default)) - '(temp-buffer-resize-mode t)) + '("dde643b0efb339c0de5645a2bc2e8b4176976d5298065b8e6ca45bc4ddf188b7" default))) (custom-set-faces ;; custom-set-faces was added by Custom. ;; If you edit it by hand, you could mess it up, so be careful. diff --git a/org/init.el b/org/init.el index 575b086..ae17a5a 100644 --- a/org/init.el +++ b/org/init.el @@ -235,4 +235,4 @@ ;; If there is more than one, they won't work right. '(custom-safe-themes '("dde643b0efb339c0de5645a2bc2e8b4176976d5298065b8e6ca45bc4ddf188b7" "bfc0b9c3de0382e452a878a1fb4726e1302bf9da20e69d6ec1cd1d5d82f61e3d" default)) - '(temp-buffer-resize-mode t)) +)