diff --git a/init b/init
index a216488d..67fae6c5 100644
--- a/init
+++ b/init
@@ -10,8 +10,8 @@
(require 'pre-settings "~/.config/emacs/settings/pre-settings.el") ;; use-package delight functions variables
(require 'which-key-settings) ;; https://melpa.org/#/which-key
(require 'general-settings) ;; requires which-key
-(require 'gui-settings) ;; emacs modeline indent rainbow focus dashboard
(require 'my-settings)
+(require 'gui-settings) ;; emacs modeline indent rainbow focus dashboard
(require 'theme-settings) ;; spacemacs-theme fonts emojify
(require 'popwin-settings) ;; https://melpa.org/#/popwin
(require 'toolbar-settings)
diff --git a/lisp/my.el b/lisp/my.el
deleted file mode 100644
index 054bf4df..00000000
--- a/lisp/my.el
+++ /dev/null
@@ -1,420 +0,0 @@
-;;; my.el --- Personal library -*- lexical-binding: t -*-
-
-;;; Commentary:
-;; Org:
-;; Colored text in Org buffer and export.
-;; [[color:gray][text]]
-;; [[color:#cccccc][text]]
-
-;;; Code:
-;; ELisp:
-;; (equal (symbol-name 'tmp) "tmp") ;; get symbol as string and compare with string
-;; (equal (intern "tmp") 'tmp) ;; get string as symbol and compare with symbol
-;; (regexp-quote "/foo/baz/*") ;; => "/foo/baz/\\*"
-;; (add-hook 'help-mode-hook 'virtual-auto-fill-mode) ;; add a mode-hook
-;; (add-hook 'org-mode-hook (lambda () (add-hook 'after-save-hook 'a-test-save-hook nil t))) ;; add local hook to a mode-hook
-;; Org:
-;; https://orgmode.org/worg/dev/org-element-api.html
-;; https://orgmode.org/worg/dev/org-syntax.html
-;; Over an element, like a table. The key must start with attr_.
-;; The lower line shows the plist elements inside the org element context.
-
-(defgroup my nil
- "My concept mapping"
- :prefix "my-"
- :group 'emacs)
-
-(defun my-eval-string (string)
- "Evaluate elisp code stored in a string."
- (eval (car (read-from-string (format "(progn %s)" string)))))
-
-(defun my-list-delete (element list)
- "Destructive version of `delete'.
-LIST will be nil if the last ELEMENT was deleted.
-Example:
- (setq my-list '(\"a\"))
- (my-list-delete \"a\" 'my-list)
- (setq my-list '(a))
- (my-list-delete 'a 'my-list)
- (add-to-list 'my-list '(\"a\"))
- (my-list-delete '(\"a\") 'my-list)"
- (set list (delete element (symbol-value list))))
-
-(defun my-list-to-org-table (lst)
- "Convert list into an Org table."
- (let ((lines lst)
- (rows)
- (tbl))
- (while lines
- (setq rows (car lines))
- (setq tbl (concat tbl "|"))
- (while rows
- (setq tbl (concat tbl (format "%s|" (car rows))))
- (setq rows (cdr rows)))
- (setq tbl (concat tbl "\n"))
- (setq lines (cdr lines)))
- tbl))
-
-(defmacro my-plist-put (plist &rest args)
- "Example usage:
- (my-plist-put my-org-table-colored-cells 'table-name '(\"@23$3\" \"blue\"))
- (my-plist-put my-org-table-colored-cells
- 'table-name-1 '(\"@13$3\" \"red\") 'table-name-2 '(\"@33$3\" \"green\"))"
- (let ((list nil))
- (while args
- (push `(setq ,plist (plist-put ,plist ,(pop args) ,(pop args))) list))
- (cons 'progn (nreverse list))))
-
-(defun my-interpolate (low high r rlow rhigh)
- "Return the point between LOW and HIGH that corresponds to where R is \
-between RLOW and RHIGH.
-
-Linear interpolate of R in the interval RLOW RHIGH.
-
-RESULT - LOW HIGH - LOW
------------- = ------------
- R - RLOW RHIGH - RLOW
-
- HIGH - LOW
-RESULT = LOW + (R - RLOW) * ------------
- RHIGH - RLOW
-
-Example:
- (my-interpolate 0 100 12 0 10) => 120"
- (+ low (/ (* (- high low) (- r rlow)) (- rhigh rlow))))
-
-(defun my-color-luminance (R G B)
- "Luminosity, relative luminance.
-
-L = 0.2126*R' + 0.7152*G' + 0.0722*B' with
-[R',G',B'] = [R,G,B] / 12.92 if [R,G,B] <= 0.03928 else (([R,G,B]+0.055)/1.055)^2.4
-earlier
-L = 0.2126*R^2.2 + 0.7152*G^2.2 + 0.0722*B^2.2
-
-R,G,B,L = [0, 1]
-See also `my-color-contrast'"
- ;; https://www.w3.org/Graphics/Color/sRGB.html
- (let ((R (if (<= R 0.03928) (/ R 12.92) (expt (/ (+ R 0.055) 1.055) 2.4)))
- (G (if (<= G 0.03928) (/ G 12.92) (expt (/ (+ G 0.055) 1.055) 2.4)))
- (B (if (<= B 0.03928) (/ B 12.92) (expt (/ (+ B 0.055) 1.055) 2.4))))
- (+ (* 0.2126 R) (* 0.7152 G) (* 0.0722 B)))
- ;; earlier
- ;;(+ (* 0.2126 (expt R 2.2)) (* 0.7152 (expt G 2.2)) (* 0.0722 (expt B 2.2)))
- )
-
-(defun my-color-contrast (R1 G1 B1 &optional R2 G2 B2)
- "Luminosity contrast ratio.
-Calculate the difference between the given colors R1, G1, B1 and R2,
-G2, B2. The returned value should be greater than or equal to 4.5
-\(earlier greater than 5) for best readability. Using
-`my-color-luminance'. R2, G2, B2 defaults to black. See also
-`color-dark-p'."
- ;; https://www.w3.org/TR/WCAG20/#contrast-ratiodef
- ;; https://www.w3.org/TR/2016/NOTE-WCAG20-TECHS-20161007/G18
- (let* ((L1 (my-color-luminance R1 G1 B1))
- (R2 (if R2 R2 0)) (G2 (if G2 G2 0)) (B2 (if B2 B2 0))
- (L2 (my-color-luminance R2 G2 B2)))
- (if (> L1 L2) ;; normally L1 defined as the lighter color and L2 as the darker color
- (/ (+ L1 0.05) (+ L2 0.05))
- (/ (+ L2 0.05) (+ L1 0.05)))))
-
-(defun my-color-rgb-gradient (rgbsteps position)
- "RGBSTEPS is a list of four element lists.
-The list consists
-- a start position value for the color d
-- and the three color parameters r g b
-- example
- '((d1 r1 g1 b1)
- (d2 r2 g2 b2)
- (d3 r3 g3 b3)
- (d4 r4 g4 b4))
- with d1 < d2 < d3 < d4
-if POSITION <= d1 then return (r1 g1 b1)
-else remove the rgbstep_i where POSITION > di+1 from RGBSTEPS
-if there is only one rgbstep left in RGBSTEPS return the (rn gn bn) values
-otherwise interpolate of the first two rgbstep elements of the remaining
-RGBSTEPS list.
-
-Examples:
- (my-rgb-gradient '((1 1 1 1) (2 2 2 2) (3 3 3 3)) 2)
- (my-rgb-gradient '((1 1 1 1) (2 2 2 2)) 2)"
- ;; if position <= first element of first element (d1)
- ;; then return other elements of first element (r1 g1 b1)
- (if (<= position (caar rgbsteps))
- (cdar rgbsteps)
- ;; if there are other elements and if position > d1(,new) of the first other element
- ;; then remove first element
- (while (and (cdr rgbsteps) (> position (caadr rgbsteps)))
- (setq rgbsteps (cdr rgbsteps)))
- ;; if there is no other element, return other elements (rn gn bn) of the element in list
- (if (null (cdr rgbsteps))
- (cdar rgbsteps)
- ;; else there are at least two elements left.
- ;; return interpolation of the first two elements
- (list
- ;; r1 g1 b1 r2 g2 b2 d1 d2
- (my-interpolate (nth 1 (car rgbsteps)) (nth 1 (cadr rgbsteps)) position (caar rgbsteps) (caadr rgbsteps))
- (my-interpolate (nth 2 (car rgbsteps)) (nth 2 (cadr rgbsteps)) position (caar rgbsteps) (caadr rgbsteps))
- (my-interpolate (nth 3 (car rgbsteps)) (nth 3 (cadr rgbsteps)) position (caar rgbsteps) (caadr rgbsteps))))))
-
-(with-eval-after-load 'org
-
- ;;; colored table cells
- ;; https://emacs.stackexchange.com/questions/7375/can-i-format-cells-in-an-org-mode-table-differently-depending-on-a-formula
- (require 'ov)
-
- (defun my-org-keywords ()
- "Parse the buffer and return a cons list of (key . value)
-from lines like:
-#+KEY: value"
- (org-element-map (org-element-parse-buffer 'greater-element) 'keyword
- (lambda (keyword) (cons (org-element-property :key keyword)
- (org-element-property :value keyword)))))
-
- (defun my-org-keyword (keyword)
- "Get the value of a KEYWORD in the form of #+KEYWORD: value
-
-Using `my-org-keywords' to find all keywords."
- (cdr (assoc keyword (my-org-keywords))))
-
- (defun my-org-keyword-re (KEYWORD)
- "Get the value from a line like this
-#+KEYWORD: value
-in a buffer.
-
-Using a case-insensitive regular expressions search in the buffer to grab the value."
- (interactive)
- (let ((case-fold-search t)
- (re (format "^#\\+%s:[ \t]+\\([^\t\n]+\\)" KEYWORD)))
- (if (not (save-excursion
- (or (re-search-forward re nil t)
- (re-search-backward re nil t))))
- (error (format "No line containing #+%s: value found" KEYWORD)))
- (match-string 1)))
-
- (defun my-org-attr-to-list (attr)
- "
-ATTR is the for example (plist-get table :attr_color)
-
-#+ATTR_MY_KEY: this and that
-:attr_my_key (\"this and that\")
-
-#+ATTR_MY_KEY: this and that
-#+ATTR_MY_KEY: foo baz
-:attr_my_key (\"this and that\" \"foo baz\")"
- ;;(split-string (car attr)) ;; this was only the first string, meaning only one (the last) attr_color line.
- ;;(split-string (string-join attr " ")) ;; splits on space but also inside quotes
- (split-string-and-unquote (string-join attr " ")))
-
- (defun my-org-table-get ()
- "Check if cursor is inside an Org table or on #+TBLFM lines \
-then return the table element otherwise return nil.
-`org-at-table-p' is nil if cursor on #+TBLFM"
- (let ((element (org-element-at-point))) ;; get org element
- (while (and element (not (eq (car element) 'table))) ;; check if it is table
- (setq element (plist-get (cadr element) :parent))) ;; if not check if parent element is table
- (cond
- ((equal (car element) 'table) ;; only if table found
- (cadr element))))) ;; return element
-
- (defun my-org-table-range-to-list (desc &optional val)
- "
-Example usage:
-\(my-org-table-range-to-list \"@3$1\") -> (@3$1)
-\(my-org-table-range-to-list \"@3$1\" \"red\") -> (@3$1 red)
-\(my-org-table-range-to-list \"@3$1..@3$3\") -> (@3$1 @3$2 @3$3)
-\(my-org-table-range-to-list \"@3$1..@3$3\" \"red\") -> (@3$1 red @3$2 red @3$3 red)
-
-Used in `my-org-table-list-of-range-to-list'"
- (if (string-match-p (regexp-quote "..") desc)
- (let (from-row from-column to-row to-column result)
- (string-match "@\\([0-9]+\\)\$\\([0-9]+\\)\\.\\.@\\([0-9]+\\)\$\\([0-9]+\\)" desc)
- (setq from-row (string-to-number (match-string 1 desc))) ;; 1st parentheses match from string-match
- (setq from-column (string-to-number (match-string 2 desc))) ;; 2nd parentheses match from string-match
- (setq to-row (string-to-number (match-string 3 desc))) ;; 3rd parentheses match from string-match
- (setq to-column (string-to-number (match-string 4 desc))) ;; 4th parentheses match from string-match
- (loop for i upfrom to-row downto from-row ;; push prepends
- do
- (cl-loop for j upfrom to-column downto from-column
- do
- (when val (push val result)) ;; push prepends
- (push (concat "@" (number-to-string i) "$" (number-to-string j)) result)
- ))
- result)
- (if val (list desc val) (list desc))))
-
- (defun my-org-table-list-of-range-to-list (seq)
- "
-@3$1..@3$3 red @1$3 #0055aa -> (@3$1 red @3$2 red @3$3 red @1$3 #0055aa)
-
-Used in `my-org-table-cell-color-attr'
-uses `my-org-table-range-to-list'"
- (when seq
- (let (result)
- ;;(message "%s" seq)
- (while seq
- (setq result
- (append result
- (my-org-table-range-to-list (car seq) (cadr seq))))
- (setq seq (cddr seq)))
- result)))
-
- (defun my-org-table-cell-color (beg end seq)
- "BEG and END are the beginning and the end of the table.
-SEQ is a list of cell name and color name pairs."
- (save-excursion ;; save cursor and go back to it after, important for other features
- (goto-char beg) ;; go inside the table, required for org-table-analyse
- (org-table-analyze) ;; required for org-table-goto-field
- (ov-clear beg end)
- (while seq ;; run as long elements are in list
- (let* ((cell (car seq)) ;; get first "key"
- (color-name (cadr seq)) ;; get first "value"
- (color-rgb (color-name-to-rgb color-name))
- (bg (apply #'color-rgb-to-hex color-rgb))
- ;;(fg (if (>= (apply #'my-color-contrast color-rgb) 4.5) "#000000" "#ffffff"))
- (fg (if (>= (apply #'my-color-contrast (append color-rgb (color-name-to-rgb "gray10"))) 4.5) "gray10" "gray80"))
- ;;(fg (if (>= (apply #'my-color-contrast color-rgb) 4.5) "gray10" 'default))
- (beg (progn (org-table-goto-field cell) (backward-char) (point))) ;; beginning of the cell
- ;;(end (progn (org-table-end-of-field 1) (forward-char) (point))) ;; for left aligned cells end is end of content not of cell
- (end (1- (plist-get (cadr (org-element-context)) :end)))
- )
- (ov beg end 'face (list :background bg
- :foreground fg))
- (setq seq (cddr seq)))))) ;; remove first element from list
-
- (defvar-local my-org-table-cell-color-list
- nil
- "Plist of table names with list of cells to color.
-It is used for the function `my-org-table-cell-color-var'.
-Example usage:
- (my-plist-put my-org-table-cell-color-list 'table-name '(\"@23$3\" \"blue\"))
- (setq my-org-table-cell-color-list '(
- table-name-1 (
- \"@33$3\" \"blue\"
- \"@34$2\" \"red\"
- \"@34$3\" \"green\"
- )
- table-name-2 (\"@13$3\" \"blue\" \"@14$2\" \"red\" \"@14$3\" \"green\")
- ))")
-
- (defun my-org-table-cell-color-var ()
- "Function to color cells.
-It uses the variable `my-org-table-cell-color-list'.
-Example usage to add a (normal, global) hook:
- (add-hook 'org-ctrl-c-ctrl-c-hook 'my-org-table-cell-color-var)
-Example usage to add a local hook:
- (add-hook 'org-ctrl-c-ctrl-c-hook 'my-org-table-cell-color-var nil t)"
- (let* ((table (my-org-table-get)) ;; get table element
- (table-name (plist-get table :name))) ;; get table name (string)
- (cond
- (table-name ;; only if table found
- (let ((begcont (plist-get table :contents-begin)) ;; :begin at the beginning of #+NAME:, #+ATTR_...
- (endcont (plist-get table :contents-end)) ;; :end at the end of #+TBLFM: ...
- (tmp-list (plist-get my-org-table-cell-color-list (intern table-name)))) ;; get value of key (string to symbol)
- (my-org-table-cell-color begcont endcont tmp-list))))))
-
- (defun my-org-table-cell-color-attr ()
- "Function to color cells.
-It uses the Org keyword #+ATTR_COLOR: CELL COLOR ...
-COLOR is either a color name (see `list-colors-display') or a
-Multiple #+ATTR_COLOR are possible. They are joint together.
-Example usage to add a (normal, global) hook:
- (add-hook 'org-ctrl-c-ctrl-c-hook 'my-org-table-cell-color-attr)
-Example usage to add a local hook:
- (add-hook 'org-ctrl-c-ctrl-c-hook 'my-org-table-cell-color-attr nil t)
-Example usage
-#+ATTR_COLOR: @1$3 #0055aa @1$1 #887744 @1$2 #008822
-#+ATTR_COLOR: @2$3 blue @2$1 yellow @2$2 green
-#+ATTR_COLOR: @3$1..@4$3 #cc0000 @5$3 red
-"
- (let* ((table (my-org-table-get)) ;; get table element
- (table-attr (plist-get table :attr_color))) ;; nil if attr not set, table can be nil
- (cond
- (table-attr ;; only if table attr found
- (let ((begcont (plist-get table :contents-begin)) ;; :begin at the beginning of #+NAME:, #+ATTR_...
- (endcont (plist-get table :contents-end)) ;; :end at the end of #+TBLFM: ...
- (color-list
- (my-org-table-list-of-range-to-list
- (my-org-attr-to-list table-attr))))
- (my-org-table-cell-color begcont endcont color-list))))))
-
- ;; colored text in org-mode using links
- ;; http://kitchingroup.cheme.cmu.edu/blog/2016/01/16/Colored-text-in-org-mode-with-export-to-HTML/
- ;; https://en.wikibooks.org/wiki/LaTeX/Colors
- ;; this will be evaluated during export
- (require 'ol)
- (require 'color)
- (require 'ov)
- (org-link-set-parameters
- "color"
- :follow
- ;;(org-add-link-type
- ;; "color"
- '(lambda (path)
- "No follow action.")
- :export
- '(lambda (color description backend)
- "if link description is empty use color as description.
-[[color:COLOR][DESCRIPTION]]"
- (cond
- ((eq backend 'html)
- (let ((rgb (color-name-to-rgb color))
- r g b)
- (if rgb
- (progn
- (setq r (truncate (* 255 (nth 0 rgb))))
- (setq g (truncate (* 255 (nth 1 rgb))))
- (setq b (truncate (* 255 (nth 2 rgb))))
- (format "%s"
- r g b
- (or description color)))
- (format "No Color RGB for %s" color))))
- ((eq backend 'latex)
- (let ((rgb (color-name-to-rgb color)))
- (if rgb
- (progn
- (format "\\textcolor[rgb]{%s,%s,%s}{%s}"
- (nth 0 rgb) (nth 1 rgb) (nth 2 rgb)
- (or description color)))
- (format "No Color RGB for %s" color))))
- )))
- (defun my-org-link-color (limit)
- "Helper function for colored text in buffer.
-Usage:
- [[color:gray][text]]
- [[color:#cccccc][text]]"
- (when (re-search-forward
- "color:[#0-9a-zA-Z]\\{2,\\}" limit t)
- (forward-char -2)
- (let ((link (org-element-context))
- color beg end post-blanks)
- (if link
- (progn
- (setq color (org-element-property :path link)
- beg (org-element-property :begin link)
- end (org-element-property :end link)
- post-blanks (org-element-property :post-blank link))
- (set-match-data
- (list beg
- (- end post-blanks)))
- (ov-clear beg end 'color)
- (ov beg
- (- end post-blanks)
- 'color t
- 'face
- `((:foreground ,color)))
- (goto-char end))
- (goto-char limit)
- nil))))
- (defun my-org-link-color-hook ()
- "activate with e.g. (add-hook 'org-mode-hook 'my-org-link-color-hook)"
- (font-lock-add-keywords
- nil
- '((my-org-link-color (0 'org-link t)))
- t)
- )
-
- ) ;; with-eval-after-load 'org
-
-(provide 'my)
-;;; my.el ends here
diff --git a/lisp/my/.#my.el b/lisp/my/.#my.el
new file mode 120000
index 00000000..0fbb4236
--- /dev/null
+++ b/lisp/my/.#my.el
@@ -0,0 +1 @@
+daniel@daniel-pc.242703:1611840040
\ No newline at end of file
diff --git a/lisp/my-view.el b/lisp/my/my-view.el
similarity index 100%
rename from lisp/my-view.el
rename to lisp/my/my-view.el
diff --git a/lisp/my/my.el b/lisp/my/my.el
index dfc84404..bf0f89e3 100644
--- a/lisp/my/my.el
+++ b/lisp/my/my.el
@@ -19,11 +19,17 @@
;; Over an element, like a table. The key must start with attr_.
;; The lower line shows the plist elements inside the org element context.
+(require 'my-view)
+
(defgroup my nil
"My concept mapping"
:prefix "my-"
:group 'emacs)
+(defun my-eval-string (string)
+ "Evaluate elisp code stored in a string."
+ (eval (car (read-from-string (format "(progn %s)" string)))))
+
(defun my-list-delete (element list)
"Destructive version of `delete'.
LIST will be nil if the last ELEMENT was deleted.
@@ -36,6 +42,21 @@ Example:
(my-list-delete '(\"a\") 'my-list)"
(set list (delete element (symbol-value list))))
+(defun my-list-to-org-table (lst)
+ "Convert list into an Org table."
+ (let ((lines lst)
+ (rows)
+ (tbl))
+ (while lines
+ (setq rows (car lines))
+ (setq tbl (concat tbl "|"))
+ (while rows
+ (setq tbl (concat tbl (format "%s|" (car rows))))
+ (setq rows (cdr rows)))
+ (setq tbl (concat tbl "\n"))
+ (setq lines (cdr lines)))
+ tbl))
+
(defmacro my-plist-put (plist &rest args)
"Example usage:
(my-plist-put my-org-table-colored-cells 'table-name '(\"@23$3\" \"blue\"))
@@ -397,114 +418,31 @@ Usage:
) ;; with-eval-after-load 'org
-(defun my-view-python ()
- "Three windows.
-On the right side a *Anaconda* buffer with optionally
-`virtual-auto-fill-mode' active and a *Python* buffer."
- (interactive)
- (require 'python)
-
- (unless (get-buffer (concat "*" python-shell-buffer-name "*"))
- (run-python) ;; cursor is now inside the python buffer.
- (other-window -1)
- )
-
- (delete-other-windows)
-
- (split-window-horizontally (truncate (* 0.6 (window-body-width))))
- (other-window 1)
- (switch-to-buffer (concat "*" python-shell-buffer-name "*"))
-
- (split-window-vertically) ;; both are python buffers now.
- (switch-to-buffer "*Anaconda*")
- (when (fboundp 'virtual-auto-fill-mode) (virtual-auto-fill-mode))
- (other-window -1)
- )
-
-(defun my-view-elisp ()
- "Two windows side-by-side.
-On the right side a *Help* buffer with optionally
-`virtual-auto-fill-mode' active."
- (interactive)
- (delete-other-windows)
-
- (split-window-horizontally (truncate (* 0.6 (window-body-width))))
- (other-window 1)
- (switch-to-buffer "*Help*")
- (other-window -1)
- )
-
-(defun my-view-shell ()
- "Two windows side-by-side.
-On the right side a *compilation* buffer.
-Use `compile' with `sh ' to run the script."
- ;; TODO: rebind compile to C-c and auto fill sh with filename
- ;; TODO: rebind recompile to ??? to use last compile command
- ;; https://masteringemacs.org/article/compiling-running-scripts-emacs
- ;; TODO: for shell-script buffers:
- ;; ;;; Shut up compile saves
- ;; (setq compilation-ask-about-save nil)
- ;; ;;; Don't save *anything*
- ;; (setq compilation-save-buffers-predicate '(lambda () nil))
- (interactive)
- (delete-other-windows)
-
- (split-window-horizontally (truncate (* 0.6 (window-body-width))))
- (other-window 1)
- (switch-to-buffer "*compilation*")
- (other-window -1)
- )
-
-(defun my-view-org-pdf ()
- "Two windows side-by-side.
-On the right side a DocView buffer displaying the pdf."
- (interactive)
- (delete-other-windows)
- (let ((bufnam (buffer-name))
- (buffilnam buffer-file-name))
- (split-window-horizontally)
- (other-window 1)
- ;;(switch-to-buffer (concat (file-name-sans-extension bufnam) ".pdf"))
- (find-file (concat (file-name-sans-extension buffilnam) ".pdf"))
- (doc-view-fit-height-to-window)
- (doc-view-fit-window-to-page)
- (other-window -1)
- ))
-
-(defun my-view-gnuplot ()
- "Three windows.
-On the right side a *Shell* buffer with optionally
-`virtual-auto-fill-mode' active and an Image mode buffer."
- (interactive)
-
- (save-excursion
- (let (output-file-name) ;; get figure output name
- (goto-char (point-min))
- (when (re-search-forward "set output .*" nil t)
- ;; TODO: search text in between set output '...' then I do not
- ;; need to replace / remove part of the match string.
- (setq output-file-name (match-string 0))
- (setq output-file-name (string-replace "set output " "" output-file-name))
- (setq output-file-name (substring output-file-name 1 -1)))
- ;;(message "%s" output-file-name)
-
- (delete-other-windows)
-
- (split-window-horizontally (truncate (* 0.6 (window-body-width))))
- (other-window 1)
- (if output-file-name
- ;;(switch-to-buffer output-file-name)
- (find-file output-file-name)
- ;;(switch-to-buffer "*scratch*")
- (switch-to-buffer " *image*"))
- ;;(when (fboundp 'virtual-auto-fill-mode) (virtual-auto-fill-mode))
-
- (split-window-vertically) ;; both are shell buffers now.
- (switch-to-buffer "*shell*")
- (shell)
- ;;(when (fboundp 'virtual-auto-fill-mode) (virtual-auto-fill-mode))
-
- (other-window -1))))
+(defun my-magit-repo-status (directory branch &optional with-update as-text)
+ (when (fboundp 'magit)
+ (let* ((default-directory directory)
+ (remotes (magit-list-remotes))
+ (diff))
+ (when (= (length remotes) 1)
+ (let* ((remote-branch-name (concat (car remotes) "/" branch)) ;; @{u} may not configured, TODO: (if (magit-rev-parse "@{u}") ...)
+ (diff-count (magit-rev-diff-count "@" remote-branch-name))) ;; i.e. git rev-list @...origin/master --count --left-right
+ (when with-update (magit-git-fetch (concat (car remotes) " " branch)))
+ (setq diff (- (car diff-count) (cadr diff-count)))))
+ (if as-text
+ (if (= diff 0) "Up-to-date"
+ (if (> diff 0) "Need to pull"
+ "Need to push"))
+ diff))))
+(defun my-dashboard-config-update ()
+ (if (fboundp 'magit)
+ (let ((diff (my-magit-repo-status "~/.config/emacs" "master")))
+ (if (= diff 0) "Up-to-date"
+ (if (= diff 1) "1 update"
+ (if (> diff 0) (format "%s updates" diff)
+ (if (= diff -1) "1 commit unpushed"
+ (format "%s commits unpushed" (- diff)))))))
+ (require 'magit nil t)
+ "Check"))
(provide 'my)
;;; my.el ends here
diff --git a/settings/gui-settings.el b/settings/gui-settings.el
index dd6c4df5..8786236d 100644
--- a/settings/gui-settings.el
+++ b/settings/gui-settings.el
@@ -236,7 +236,8 @@
;; (list "?" "" "?/h" (lambda (&rest _) (describe-mode)) nil "<" ">") ;;#'show-help
;; )))
(require 'all-the-icons)
- (setq dashboard-navigator-buttons ;; Format: "(icon title help action face prefix suffix)"
+ (defun dashboard-navigator-buttons-func ()
+ ;; Format: "(icon title help action face prefix suffix)"
`(( ;; views
("" "Custom Views:" "custom views" nil default "" "")
(,(all-the-icons-fileicon "elisp" :height 1.0 :v-adjust -0.1)
@@ -250,12 +251,12 @@
(,(all-the-icons-octicon "file-pdf" :height 1.0 :v-adjust 0.0)
"Org PDF" "my-view-org-pdf" (lambda (&rest _) (my-tab-view-org-pdf)))
)
- ( ;; major modes
+ ( ;; major modes first line
("" "Major Modes:" "major modes" nil default "" "")
(""
"Deft" "deft" (lambda (&rest _) (deft)))
(""
- "EShell" "eshell-mode" (lambda (&rest _) (eshell-mode)))
+ "EShell" "eshell-mode" (lambda (&rest _) (eshell)))
(""
"Magit" "magit" (lambda (&rest _) (magit)))
(,(all-the-icons-octicon "mail" :height 1.0 :v-adjust 0.0)
@@ -281,8 +282,10 @@
"Help" "?/h" (lambda (&rest _) (describe-mode)) nil) ;; #'show-help
(,(all-the-icons-material "refresh" :height 1.1 :v-adjust -0.15) ;; all-the-icons-octicon "sync"
"Restart" "restart-emacs" (lambda (&rest _) (restart-emacs)) nil)
+ ("" ,(concat "Config: " (my-dashboard-config-update)) "config" (lambda (&rest _) (progn (my-dashboard-config-update) (setq dashboard-navigator-buttons (dashboard-navigator-buttons-func)) (dashboard-refresh-buffer))) default "" "")
)))
- (setq dashboard-items '((recents . 5)
+ (setq dashboard-navigator-buttons (dashboard-navigator-buttons-func))
+ (setq dashboard-items '((recents . 10)
(bookmarks . 5)
;;(projects . 5)
;;(agenda . 5)