(set-background-color "#000000")
defined in the default .emacs file used for emacs init to work on various computers
User org-mode file directory: ads/user-dir-org defined in default .emacs config file Personal org directory (see all tasks on work computer and shared inbox) ads/personal-dir-org ads/user-dir-readme - this files full path ads/user-dir-config directory for the actual config file used when running set ads/computer-id currently: work Personal(add-to-list 'load-path ads/user-dir-emacs)
(add-to-list 'load-path ads/user-dir-org)
(setq debug-on-error t)
;; Initialize package sources
(require 'package)
(setq package-archives '(("melpa" . "https://melpa.org/packages/")
("gnu" . "https://elpa.gnu.org/packages/")
("nongnu" . "https://elpa.nongnu.org/nongnu/")
("org" . "https://orgmode.org/elpa/")
("elpa" . "https://elpa.gnu.org/packages/")
))
(if (not package--initialized)
(package-initialize))
(unless package-archive-contents
(package-refresh-contents))
;; Initialize use-package on non-Linux platforms
(unless (package-installed-p 'use-package)
(package-install 'use-package))
(require 'use-package)
(setq use-package-always-ensure t)
(setq-default
cursor-in-non-selected-windows nil ; Hide the cursor in inactive windows
require-final-newline t ; Newline at end of file
scroll-margin 3 ; Add a margin when scrolling vertically
scroll-conservatively 10 ; Avoid recentering when scrolling far
help-window-select t ; Focus new help windows when opened
initial-scratch-message "Welcome back" ; Empty the initial *scratch* buffer
visible-bell nil ; set up the visible bell (no annoying beeping sounds)
inhibit-startup-echo-area-message t
inhibit-startup-screen t
)
(blink-cursor-mode 0) ; Prefer a still cursor
(fset 'yes-or-no-p 'y-or-n-p) ; Replace yes/no prompts with y/n
(global-subword-mode 1) ; Iterate through CamelCase words
(put 'downcase-region 'disabled nil) ; Enable downcase-region
(put 'upcase-region 'disabled nil) ; Enable upcase-region
(scroll-bar-mode -1) ; Disable the visible scrollbar
(tool-bar-mode -1) ; Disablet the toolbar
(tooltip-mode -1) ; Disable tooltips
(menu-bar-mode -1) ; Disable the menu bar
(set-fringe-mode 10) ; Add some breathing room
(setq backup-directory-alist '(("." . "~/.emacs.d/backup"))
backup-by-copying t ; Don't delink hardlinks
version-control t ; Use version numbers on backups
delete-old-versions t ; Automatically delete excess backups
kept-new-versions 20 ; how many of the newest versions to keep
kept-old-versions 5 ; and how many of the old
)
(setq backup-enable-predicate
(lambda (name)
(and (normal-backup-enable-predicate name)
(not
(let ((method (file-remote-p name 'method)))
(when (stringp method)
(member method '("su" "sudo"))))))))
(add-to-list 'display-buffer-alist
(cons "\\*Async Shell Command\\*.*" (cons #'display-buffer-no-window nil)))
(setq read-only-directories '( ) )
(defun find-file-read-only-directories ()
"""
start buffer in read only mode if file in a child directory
of in any of the directores defined in read-only-directories
"""
(dolist (read-only-directory read-only-directories)
;; (print read-only-directory)
(when
(string-search read-only-directory buffer-file-name)
(read-only-mode)
;; (print "open normally")
)
))
(add-hook 'find-file-hook 'find-file-read-only-directories)
(defmacro f-string (fmt)
"Like `s-format' but with format fields in it.
FMT is a string to be expanded against the current lexical
environment. It is like what is used in `s-lex-format', but has
an expanded syntax to allow format-strings. For example:
${user-full-name 20s} will be expanded to the current value of
the variable `user-full-name' in a field 20 characters wide.
(let ((f (sqrt 5))) (f-string \"${f 1.2f}\"))
will render as: 2.24
This function is inspired by the f-strings in Python 3.6, which I
enjoy using a lot.
"
(let* ((matches (s-match-strings-all"${\\(?3:\\(?1:[^} ]+\\) *\\(?2:[^}]*\\)\\)}" fmt))
(agetter (cl-loop for (m0 m1 m2 m3) in matches
collect `(cons ,m3 (format (format "%%%s" (if (string= ,m2 "")
(if s-lex-value-as-lisp "S" "s")
,m2))
(symbol-value (intern ,m1)))))))
`(s-format ,fmt 'aget (list ,@agetter))))
(if (string= system-type "gnu/linux")
(setq
serif "Etbb"
mono "Fira Code Nerd Font")
(setq
serif "EtBembo"
mono "FiraCode Nerd Font"))
(setq sans "Cantarell")
;; Set Font sizes
(defvar ads/default-font-size 160)
(defvar ads/default-variable-font-size 160)
;Set line spacing
(setq line-spacing .2)
;; Set default font
(set-face-attribute 'default nil :font mono :height ads/default-font-size)
;; Set the fixed pitch face
(set-face-attribute 'fixed-pitch nil :font mono :height ads/default-font-size)
;; Set the variable pitch fa
(set-face-attribute 'variable-pitch nil :font serif :height ads/default-variable-font-size :weight 'regular)
;; Enable line numbers
;; (global-display-line-numbers-mode nil)
;; Disable lines in some modes
(dolist (mode '(prog-mode-hook
))
(add-hook mode(lambda () (display-line-numbers-mode 1))))
(column-number-mode)
(use-package rainbow-delimiters
:hook (prog-mode . rainbow-delimiters-mode))
In my clumsyness I’ve hit theste too many times
(global-set-key (kbd "C-x C-c") 'nil)
(global-set-key (kbd "C-x C-z") 'nil)
- tutorial
- hello
- help for help
(global-set-key (kbd "C-h t") 'nil)
(global-set-key (kbd "C-h h") 'nil)
(global-set-key (kbd "C-h C-h") 'nil)
(defvar-local hidden-mode-line-mode nil)
(define-minor-mode hidden-mode-line-mode
"Minor mode to hide the mode-line in the current buffer."
:init-value nil
:global t
:variable hidden-mode-line-mode
:group 'editing-basics
(if hidden-mode-line-mode
(setq hide-mode-line mode-line-format
mode-line-format nil)
(setq mode-line-format hide-mode-line
hide-mode-line nil))
(force-mode-line-update)
;; Apparently force-mode-line-update is not always enough to
;; redisplay the mode-line
(redraw-display)
(when (and (called-interactively-p 'interactive)
hidden-mode-line-mode)
(run-with-idle-timer
0 nil 'message
(concat "Hidden Mode Line Mode enabled. "
"Use M-x hidden-mode-line-mode to make the mode-line appear."))))
;;Make ESC quit prompts (why wouldn't you want that?)
(global-set-key (kbd "<escape>") 'keyboard-escape-quit)
(define-key global-map (kbd "C-SPC") 'nil)
(use-package general
:after evil
:config
(general-create-definer ads/leader-keys
:keymaps '(normal insert visual emacs)
:prefix "SPC"
:global-prefix "C-SPC")
(ads/leader-keys
"t" '(:ignore t :wk "toggles")
"j" '(:ignore t :which-key "org")
"er" '(lambda () (interactive)
(find-file (concat ads/user-dir-readme))
:wk "Readme Config")
"ew" '(lambda () (interactive)
(find-file "c:/users/adanaos/git/emacs-work/work-config.org")
:wk "Work Config")
"e." '(lambda () (interactive)
(find-file ads/user-dir-config)
:wk ".emacs Config")
"ei" '(lambda () (interactive) (find-file (concat ads/user-dir-emacs "init.el"))
:which-key "ORG init")
"ez" '(lambda () (interactive)
(find-file (concat ads/git-dir "zmk-config/config/corne.keymap"))
:wk "ZMK Config")
"eZ" '(lambda () (interactive)
(counsel-find-file (concat ads/git-dir "zmk-config/"))
:wk "ZMK Config")
"e" '(:ignore t :whch-key "eval")
"eb" '(eval-buffer :which-key "eval-buffer")
"ep" '(eval-last-sexp :which-key "eval-last-sexp")
"eo" '(org-mode-restart :which-key "org-mode-restart")
"k" '(:ignore t :wk "kill")
"kj" '(kill-buffer-and-window :which-key "kill-buffer-and-window")
"kk" '(kill-this-buffer :which-key "kill-this-buffer")
"kl"'(delete-window :wk "delete-window")
))
(define-key global-map (kbd "C-SPC C-SPC") 'jump-to-register)
(define-key global-map (kbd "C-SPC C-;") 'point-to-register)
(define-key global-map (kbd "C-x C-b") 'bookmark-jump)
(use-package evil
:init
(setq evil-want-integration t)
(setq evil-want-keybinding nil)
(setq evil-want-C-u-scroll nil)
(setq evil-want-C-i-jump nil)
(setq evil-want-C-w-delete nil)
:config
(evil-mode 1)
(define-key evil-insert-state-map (kbd "C-g") 'evil-normal-state)
(define-key evil-normal-state-map (kbd "q") 'nil)
;; Use visual line motions even outside of visual-line mode buffers
(evil-global-set-key 'motion "j" 'evil-next-visual-line)
(evil-global-set-key 'motion "k" 'evil-previous-visual-line)
(evil-set-initial-state 'messages-buffer-mode 'normal)
(evil-set-initial-state 'dashboard-mode 'normal))
(use-package evil-collection
:after evil
:config
(evil-collection-init))
(defun ads/toggle-lines ()
(interactive)
(toggle-truncate-lines)
;; (visual-line-mode)
(when (eq major-mode 'org-mode)
(visual-fill-column-mode `toggle)))
(ads/leader-keys
"tl" '(ads/toggle-lines :wk"toggle truncate")
)
(add-hook 'after-save-hook 'evil-normal-state)
(setq delete-trailing-lines nil)
(add-hook 'before-save-hook 'delete-trailing-whitespace)
(evil-global-set-key 'normal (kbd "C-M-j") 'counsel-switch-buffer)
(evil-global-set-key 'normal (kbd "C-w C-h") 'evil-window-left)
(evil-global-set-key 'insert (kbd "C-w C-h") (lambda () (interactive)
;; (normal-mode)
(call-interactively 'evil-window-left)))
(evil-global-set-key 'normal (kbd "C-w C-j") 'evil-window-down)
(evil-global-set-key 'insert (kbd "C-w C-j") (lambda () (interactive)
;; (normal-mode)
(call-interactively 'evil-window-down)))
(evil-global-set-key 'normal (kbd "C-w C-k") 'evil-window-up)
(evil-global-set-key 'insert (kbd "C-w C-k") (lambda () (interactive)
;; (normal-mode)
(call-interactively 'evil-window-up)))
(evil-global-set-key 'normal (kbd "C-w C-l") 'evil-window-right)
(evil-global-set-key 'insert (kbd "C-w C-l") (lambda () (interactive)
;; (normal-mode)
(call-interactively 'evil-window-right)))
(evil-global-set-key 'normal (kbd "C-w C-e") 'balance-windows)
(evil-global-set-key 'insert (kbd "C-w C-e") (lambda () (interactive)
;; (normal-mode)
(call-interactively 'balance-windows)))
(evil-global-set-key 'normal (kbd "C-w C-n") 'tear-off-window)
(use-package undo-tree
:diminish undo-tree-mode
:config
(progn
(global-undo-tree-mode)
(setq evil-undo-system 'undo-tree)
(setq undo-tree-visualizer-timestamps t)
(setq undo-tree-visualizer-diff t)
(setq undo-tree-history-directory-alist '(("." . "~/.undo-tree-history")))))
(evil-global-set-key 'normal (kbd "C-x C-u") 'undo-tree-visualize)
(defun ads/remove-newlines-in-region ()
"Removes all newlines in the region."
(interactive)
(save-restriction
(narrow-to-region (point) (mark))
(goto-char (point-min))
(while (search-forward "\n" nil t) (replace-match " " nil t))))
(defun ads/format-dir-winstyle ()
"Removes all newlines in the region."
(interactive)
(save-restriction
(narrow-to-region (point) (mark))
(goto-char (point-min))
(while (search-forward "\\" nil t) (replace-match "\\\\" nil t))))
(ads/leader-keys
"r" '(:ignore t :wk "replace")
"rr" 'replace-regexp
"rn" '(ads/remove-newlines-in-region :wk "remove new lines")
"rs" '(ads/format-dir-winstyle :wk "format dir style windows")
)
(evil-global-set-key 'normal (kbd "M-;") 'comment-line)
(evil-global-set-key 'insert (kbd "M-;") 'comment-line)
(evil-global-set-key 'visual (kbd "M-;") 'comment-line)
foo-theme.el
but I’m not about to rewrite something minor
(setq custom-theme-directory ads/user-dir-emacs)
(defvar ads/switch-themes-var
(let ((themes-list (list
'ads-dark
'ads-light
)))
(nconc themes-list themes-list))
"A circular list of themes to keep switching between.
Make sure that the currently enabled theme is at the head of this
list always.
A nil value implies no custom theme should be enabled.")
(use-package doom-themes
:init
(load-theme (car ads/switch-themes-var) t)
)
Toggle between themes, bound to SCP-tt
If on windows toggle app theme as well
(defun ads/quick-switch-theme ()
"Switch between to commonly used faces in Emacs.
One for writing code and the other for reading articles."
(interactive)
(dolist (theme custom-enabled-themes)
(disable-theme theme))
(if-let* ((next-theme (cadr ads/switch-themes-var)))
(progn (when-let* ((current-theme (car ads/switch-themes-var)))
(disable-theme (car ads/switch-themes-var)))
(load-theme next-theme t)
(message "Loaded theme: %s" next-theme))
;; Always have the dark mode-line theme
(mapc #'disable-theme (delq 'smart-mode-line-dark custom-enabled-themes)))
(setq ads/switch-themes-var (cdr ads/switch-themes-var))
(when
(string= system-type "windows-nt")
(ads/windows-align-emacs-darkmode))
)
(ads/leader-keys
"tt" '(ads/quick-switch-theme :wk "toggle theme"))
(defun ads/refresh-theme ()
(interactive)
(load-theme (car custom-enabled-themes) t)
)
(ads/leader-keys "tj" 'ads/refresh-theme)
(defun ads/refresh-theme-auto()
(when (cl-search
(symbol-name (car custom-enabled-themes))
(file-name-base buffer-file-name))
(ads/refresh-theme)))
(add-hook 'after-save-hook #'ads/refresh-theme-auto)
(defun ads/toggle-transparency ()
(interactive)
(let ((alpha (frame-parameter nil 'alpha)))
(set-frame-parameter
nil 'alpha
(if (eql (cond ((numberp alpha) alpha)
((numberp (cdr alpha)) (cdr alpha))
;; Also handle undocumented (<active> <inactive>) form.
((numberp (cadr alpha)) (cadr alpha)))
100)
'(92 . 92) '(100 . 100)))))
(ads/leader-keys "tr"'(ads/toggle-transparency :wk "toggle transparency"))
(use-package all-the-icons)
;; Doom modeline config
(use-package doom-modeline
:ensure t
:init (doom-modeline-mode 1)
)
(set-face-attribute 'doom-modeline nil :font mono)
(setq frame-title-format "%b")
(use-package which-key
:defer 0
:diminish which-key-mode
:config
(which-key-mode)
(setq which-key-idle-delay 0.3))
(use-package counsel
:bind (("C-M-j" . 'counsel-switch-buffer)
:map minibuffer-local-map
("C-r" . 'counsel-minibuffer-history))
:custom
(counsel-linux-app-format-function #'counsel-linux-app-format-function-name-only)
:config
(counsel-mode 1))
(defun counsel-find-file-read-only (fpath)
(interactive)
(counsel-find-file fpath)
(read-only-mode))
(use-package ivy
:diminish ;; Hides from the mode line
:bind (("C-s" . swiper)
:map ivy-minibuffer-map
("TAB" . ivy-alt-done)
("C-l" . ivy-alt-done)
("C-j" . ivy-next-line)
("C-k" . ivy-previous-line)
:map ivy-switch-buffer-map
("C-k" . ivy-previous-line)
("C-l" . ivy-done)
("C-d" . ivy-switch-buffer-kill)
:map ivy-reverse-i-search-map
("C-k" . ivy-previous-line)
("C-d" . ivy-reverse-i-search-kill))
:config
(ivy-mode 1))
(use-package ivy-rich
:after ivy
:init
(ivy-rich-mode 1))
(define-key ivy-minibuffer-map (kbd "S-SPC") 'nil) ;
Still not working ¯\_(ツ)_/¯ not sure why though, saying Ivy Prescient is not on melpa
(use-package ivy-prescient
:after counsel
:custom
(ivy-prescient-enable-filtering nil)
:config
;; Uncomment the following line to have sorting remembered across sessions!
(prescient-persist-mode 1)
(ivy-prescient-mode 1))
(use-package helpful
:ensure t
:commands (helpful-callable helpful-variable helpful-command helpful-key)
:custom
(counsel-describe-function-function #'helpful-callable)
(counsel-describe-variable-function #'helpful-variable)
:bind
([remap describe-function] . counsel-describe-function)
([remap describe-command] . helpful-command)
([remap describe-variable] . counsel-describe-variable)
([remap describe-key] . helpful-key))
(global-set-key (kbd "C-h C-v") 'describe-variable)
(global-set-key (kbd "C-h C-f") 'describe-function)
(global-set-key (kbd "C-h C-b") 'describe-bindings)
(global-set-key (kbd "C-h C-c") 'describe-key-briefly)
(global-set-key (kbd "C-h C-k") 'describe-key)
(global-set-key (kbd "C-h C-e") 'view-echo-area-messages)
(global-set-key (kbd "C-h C-j") 'describe-face)
(use-package browse-kill-ring
:ensure t
:config
;; (browse-kill-ring-default-keybindings) ended up setting this myself down below same thing but I know what idiot set it
(setq browse-kill-ring-highlight-current-entry t)
)
(global-set-key (kbd "M-y") 'browse-kill-ring)
;; I like my evil bindings
(define-key browse-kill-ring-mode-map (kbd "j") 'browse-kill-ring-forward)
(define-key browse-kill-ring-mode-map (kbd "k") 'browse-kill-ring-previous)
(use-package hydra
:defer t)
(defhydra hydra-text-scale (:timeout 2)
"scale text"
("j" text-scale-increase "in")
("k" text-scale-decrease "out")
("f" nil "finished" :exit t))
(ads/leader-keys
"ts" '(hydra-text-scale/body :which-key "scale text"))
(defhydra hydra-window-adjust (:timeout 5)
("k" (evil-window-increase-height 5) "increase height")
("j" (evil-window-decrease-height 5) "decrease height")
("h" (evil-window-increase-width 10) "increase width")
("l" (evil-window-decrease-width 10) "decrease width")
("e" balance-windows "balance windows")
("f" nil "finished" :exit t)
)
(ads/leader-keys "C-w" '(hydra-window-adjust/body :wk "hydra window adjust"))
(use-package evil-smartparens)
(use-package smartparens-config
:ensure smartparens
:config (progn (show-smartparens-global-mode t)))
(require 'smartparens-config)
(add-hook 'prog-mode-hook 'turn-on-smartparens-strict-mode)
(add-hook 'markdown-mode-hook 'turn-on-smartparens-strict-mode)
(add-hook 'smartparens-enabled-hook #'evil-smartparens-mode)
(show-paren-mode t)
(use-package emojify
:hook (after-init . global-emojify-mode)
:config
(setq emojify-emoji-styles '(unicode))
)
(add-hook 'after-init-hook #'global-emojify-mode)
(setq emojify-emoji-styles '(ascii unicode))
(ads/leader-keys
";" '(emojify-insert-emoji :wk "insert emoji")
)
(defun ads/org-mode-setup ()
(interactive)
;; (org-indent-mode t)
(variable-pitch-mode 1)
(visual-line-mode 1)
(setq org-image-actual-width (/ (car (window-text-pixel-size)) 1.5))
;; (org-redisplay-inline-images)
;; Replace list hyphen with dots
(font-lock-add-keywords 'org-mode
'(("^ *\\([-]\\) "
(0 (prog1 () (compose-region (match-beginning 1) (match-end 1) "•"))))))
)
(add-hook 'org-mode-hook 'ads/org-mode-setup)
(ads/leader-keys "of" '(ads/org-mode-setup :wk "org mode setup fn"))
(ads/leader-keys
"o" '(:ignore t :wk "org")
"oc" '(org-capture :wk "capture")
"oj" '(org-store-link :wk "org-store-link")
"oi" '(org-insert-last-stored-link :wk "org-insert-last-stored-link")
)
(global-set-key (kbd "C-x C-n") 'nil)
(defun ads/org-toggle-narrow ()
(interactive)
(if (buffer-narrowed-p)
(widen)
(org-narrow-to-subtree)))
(ads/leader-keys
"n" '(:ignore t :wk "org Narrow")
"C-n" '(ads/org-toggle-narrow :wk "Toggle Narrow")
"ns" '(org-narrow-to-subtree :wk "Subtree")
"ne" '(org-narrow-to-element :wk "Element")
"nb" '(org-narrow-to-block :wk "Block")
"nd" '(narrow-to-defun :wk "Defun")
"nn" '(narrow-to-region :wk "Region")
"nw" '(widen :wk "Widen")
)
(use-package org
:config
(setq org-ellipsis " ▾ "
org-directory ads/user-dir-org
org-agenda-start-with-log-mode t
org-log-done 'time
org-log-into-drawer t
org-pretty-entities t
org-pretty-entities-include-sub-superscripts nil
org-hidden-keywords '(title)
org-hide-emphasis-markers t
org-src-preserve-indentation t
org-image-actual-width (/ (car (window-text-pixel-size)) 2)
org-startup-with-inline-images t
org-startup-indented t
org-startup-folded t
org-agenda-block-separator ""
org-fontify-whole-heading-line t
org-fontify-done-headline t
org-fontify-quote-and-verse-blocks t
org-bullets-bullet-list '(" ") ;; no bullets, needs org-bullets package
org-cycle-separator-lines 0
org-id-link-to-org-use-id t
org-blank-before-new-entry '((heading . nil)
(plain-list-item . nil))
)
;:hook (org-mode . ads/org-mode-setup)
(require 'org-habit)
(require 'org-attach)
(add-to-list 'org-modules 'org-habit 'org-checklist)
(setq org-habit-graph-column 60)
(setq org-todo-keywords
'((sequence "TODO(t)" "|" "DONE(d!)")
(sequence "BACKLOG(b)" "PLAN(p)" "READY(r)"
"ACTIVE(a)" "REVIEW(v)" "WAIT(w@/!)" "HOLD(h)" "|" "COMPLETED(c)" "CANC(k@)")))
;; Save Org buffers after refiling!
(advice-add 'org-refile :after 'org-save-all-org-buffers)
(setq org-tag-alist
'((:startgroup)
; Put mutually exclusive tags here
(:endgroup)
("@errand" . ?E)
("@home" . ?H)
("@work" . ?W)
("agenda" . ?a)
("planning" . ?p)
("publish" . ?P)
("batch" . ?b)
("note" . ?n)
("idea" . ?i)))
(org-indent-mode t)
(variable-pitch-mode 1)
(visual-line-mode 1)
(put 'narrow-to-region 'disabled nil)
)
(defun ads/org-add-ids-to-headlines-in-file ()
"Add ID properties to all headlines in the current file which
do not already have one."
(interactive)
(org-map-entries 'org-id-get-create))
(add-hook 'org-mode-hook
(lambda ()
(add-hook 'before-save-hook
'ads/org-add-ids-to-headlines-in-file nil 'local)))
emacs - Completely hide the :PROPERTIES: drawer in org-mode - Stack Overflow
(defun org-cycle-hide-drawers (state)
"Re-hide all drawers after a visibility state change."
(when (and (derived-mode-p 'org-mode)
(not (memq state '(overview folded contents))))
(save-excursion
(let* ((globalp (memq state '(contents all)))
(beg (if globalp
(point-min)
(point)))
(end (if globalp
(point-max)
(if (eq state 'children)
(save-excursion
(outline-next-heading)
(point))
(org-end-of-subtree t)))))
(goto-char beg)
(while (re-search-forward org-drawer-regexp end t)
(save-excursion
(beginning-of-line 1)
(when (looking-at org-drawer-regexp)
(let* ((start (1- (match-beginning 0)))
(limit
(save-excursion
(outline-next-heading)
(point)))
(msg (format
(concat
"org-cycle-hide-drawers: "
"`:END:`"
" line missing at position %s")
(1+ start))))
(if (re-search-forward "^[ \t]*:END:" limit t)
(outline-flag-region start (point-at-eol) t)
(user-error msg))))))))))
;;(org-cycle-hide-drawers 'overview)
(defun ads/copy-id-to-clipboard()
"Copy the ID property value
to killring, if no ID is there then create a new unique ID.
This function works only in org-mode buffers.
The purpose of this function is to easily construct id:-links to
org-mode items. If its assigned to a key it saves you marking the
text and copying to the killring."
(interactive)
(when (eq major-mode 'org-mode) ; do this only in org-mode buffers
(setq mytmpid (funcall 'org-id-get-create))
(kill-new mytmpid)
(message "Copied %s to killring (clipboard)" mytmpid)
))
(ads/leader-keys "C-l" '(ads/copy-id-to-clipboard :wk "ID to clipboard"))
(setq ads/conf-task-file (concat ads/personal-dir-org "conf-tasks.org"))
(setq ads/work-task-file (concat ads/user-dir-org "work.org"))
(if (string= ads/computer-id "personal")
(setq org-refile-targets
(list
'("personal.org" :maxlevel . 1)
'(ads/conf-task-file :maxlevel . 1))))
(if (string= ads/computer-id "work")
(setq org-refile-targets
(list
'(ads/work-task-file :maxlevel . 1)
'(ads/conf-task-file :maxlevel . 1))))
;; Save Org buffers after refiling!
;; Save Org buffers after refiling!
(advice-add 'org-refile :after 'org-save-all-org-buffers)
(setq org-archive-location "archive.org::datetree/")
(ads/leader-keys
"C-a" '(org-archive-subtree :wk "org-archive-subtree"))
(use-package org-appear)
(add-hook 'org-mode-hook 'org-appear-mode)
(setq org-appear-autolinks t)
(setq org-appear-autoentities t)
(setq org-appear-autosubmarkers t)
(setq org-appear-autokeywords t)
(add-hook 'evil-insert-state-exit-hook
(lambda ()
(setq org-appear-delay 2)))
(add-hook 'evil-insert-state-entry-hook
(lambda ()
(setq org-appear-delay .3)))
Check computer ID before setting org agenda
(setq org-agenda-files (list
(concat ads/personal-dir-org "dates.org")
(concat ads/personal-dir-org "inbox.org")
;(concat ads/personal-dir-org "conf-tasks.org")
))
(if (string= ads/computer-id "work")
(add-to-list 'org-agenda-files
(concat ads/user-dir-org "work.org")))
(if (string= ads/computer-id "personal")
(progn
(add-to-list 'org-agenda-files
(concat ads/personal-dir-org "habits.org"))
(add-to-list 'org-agenda-files
(concat ads/personal-dir-org "personal.org"))))
(defun ads/org-agenda-open ()
(interactive)
;; (evil-window-split)
;; (evil-window-down 1)
(org-agenda nil "a"))
(ads/leader-keys
"oa"'(ads/org-agenda-open :wk "org-agenda"))
(defun ads/org-agenda-quit ()
(interactive)
(org-agenda-quit)
(delete-window))
(evil-define-key 'motion org-agenda-mode-map
(kbd "q") 'ads/org-agenda-quit)
(setq org-agenda-window-setup 'current-window
org-agenda-span 1
org-agenda-restore-windows-after-quit t
org-agenda-persistent-filter t
org-agenda-skip-function-global '(org-agenda-skip-entry-if 'todo 'done))
(setq org-agenda-scheduled-leaders '("" "%2d :"))
(defun ads/org-prettify-symbols-alist ()
;; I'm not happy with how these look, I'll have to figure out somethings at a future date
;; (push '("[ ]" . "☐" ) prettify-symbols-alist)
;; (push '("[X]" . "☑" ) prettify-symbols-alist)
;; (push '("[-]" . "❍" ) prettify-symbols-alist)
(push '("#+BEGIN_QUOTE" . "“") prettify-symbols-alist)
(push '("#+END_QUOTE" . "”") prettify-symbols-alist)
(push '("#+begin_quote" . "“") prettify-symbols-alist)
(push '("#+end_quote" . "”") prettify-symbols-alist)
(push '("#+BEGIN_SRC" . "«") prettify-symbols-alist)
(push '("#+END_SRC" . "»") prettify-symbols-alist)
(push '("#+begin_example" . "«") prettify-symbols-alist)
(push '("#+end_example" . "»") prettify-symbols-alist)
(push '("#+begin_src" . "«") prettify-symbols-alist)
(push '("#+end_src" . "»") prettify-symbols-alist)
(push '("#+options:" . "⌥") prettify-symbols-alist)
(push '("#+RESULTS:" . "🠶") prettify-symbols-alist)
(push '(":PROPERTIES:" ."⚙" ) prettify-symbols-alist)
(push '("emacs-lisp" ."ε" ) prettify-symbols-alist)
(prettify-symbols-mode))
(add-hook 'org-mode-hook 'ads/org-prettify-symbols-alist)
(setq diary-file (concat ads/user-dir-org "diary.org"))
(setq org-capture-templates
(list '( "c" "Task" entry
(file+headline (lambda () (concat ads/personal-dir-org "inbox.org"))"Inbox")
"* TODO %^{Task}
SCHEDULED: %t
:PROPERTIES:
:ID: \t%(org-id-new)
:CREATED:\t%U
:REF:\t%a
:END:
%?\n
"
:kill-buffer t)))
(if (string= ads/computer-id "work")
(add-to-list 'org-capture-templates
'("w" "Work Task" entry
(file+headline (lambda () (concat ads/user-dir-org "work.org"))"Tasks")
"* TODO %^{Work Task}
SCHEDULED: %t
:PROPERTIES:
:ID: \t%(org-id-new)
:CREATED:\t%U
:REF:\t%a
:END:
%?\n
"
:kill-buffer t)
))
(add-to-list 'org-capture-templates
'("p" "Personal Task" entry
(file+headline (lambda () (concat ads/personal-dir-org "personal.org"))"Tasks")
"* TODO %^{Personal Task}
SCHEDULED: %t
:PROPERTIES:
:ID: \t%(org-id-new)
:CREATED:\t%U
:REF:\t%a
:END:
%?\n
"
:kill-buffer t)
)
(add-to-list 'org-capture-templates
'("i" "Quick Inbox" entry
(file+headline (lambda () (concat ads/personal-dir-org "inbox.org"))"Inbox")
"* TODO %^{Task to inbox}
SCHEDULED: %t
:PROPERTIES:
:ID: \t%(org-id-new)
:CREATED:\t%U
:REF:\t%a
:END:
"
:immediate-finish t
:kill-buffer t)
)
(ads/leader-keys
"c" '(lambda () (interactive) (org-capture nil "i") :wk "Capture to Inbox"))
(add-to-list 'org-capture-templates
'("k" "Clipboard Link to Inbox" entry
(file+headline (lambda () (concat ads/personal-dir-org "inbox.org"))"Inbox")
"* TODO %(org-cliplink-capture)
SCHEDULED: %t
:PROPERTIES:
:ID: \t%(org-id-new)
:CREATED:\t%U
:REF:\t%a
:END:
"
:immediate-finish t
:kill-buffer t)
)
(add-to-list 'org-capture-templates
'("P" "Project" entry
(file+headline (lambda () (concat ads/personal-dir-org "personal.org"))"Projects")
"* TODO %^{Project Name}
:PROPERTIES:
:ID: \t%(org-id-new)
:CREATED:\t%U
:REF:\t%a
:Effort: \t%^{effort|1:00|2:00|4:00|8:00|16:00}
:Cost-est:\t%^{Cost estimate}
:END:
%?\n
"
:kill-buffer t)
)
(add-to-list 'org-capture-templates
'("B" "Book" entry
(file+headline (lambda () (concat ads/personal-dir-org "books.org"))"Endless Pile")
"* PILE %^{Book Title}
:PROPERTIES:
:ID: \t%(org-id-new)
:CREATED:\t%U
:AUTHOR:
:RECCOMMENDER:
:END:
%?\n
"
:kill-buffer t)
)
(add-to-list 'org-capture-templates
'("t" "Quote" entry
(file (lambda () (concat ads/personal-dir-org "quotes.org")))
"* %^{Quote or Note}
:PROPERTIES:
:ID: \t%(org-id-new)
:CREATED:\t%U
:SOURCE: %^{Source}
:REF: \t%a
:END:
%?\n
"
:kill-buffer t))
(add-to-list 'org-capture-templates
'("l" "Log to Archive" entry
(file+datetree (lambda () (concat ads/user-dir-org "archive.org")) )
"* %U
:PROPERTIES:
:ID:\t%(org-id-new)
:REF:\t%a
:FILE:\t%f
:TASK_CLOCK:\t%K
:END:
\n%?\n
"
:kill-buffer t)
)
(defun ads/log-to-archive ()
(interactive)
(org-capture nil "l")
(evil-insert-state)
)
(ads/leader-keys
"l" '(ads/log-to-archive :wk "Log to Archive"))
(add-to-list 'org-capture-templates
'("L" "Log to Archive Subject" entry
(file+datetree (lambda () (concat ads/user-dir-org "archive.org")) )
"* %^{Subject} %U
:PROPERTIES:
:ID:\t%(org-id-new)
:REF:\t%a
:FILE:\t%f
:TASK_CLOCK:\t%K
:END:
\n%?\n
"
:kill-buffer t)
)
(defun ads/log-to-archive-subject ()
(interactive)
(org-capture nil "L")
(evil-insert-state)
)
(ads/leader-keys
"L" '(ads/log-to-archive-subject :wk "Log to Archive"))
(use-package org-bullets
:after org
:hook (org-mode . org-bullets-mode)
)
(customize-set-variable 'fill-column 100)
(defun ads/org-mode-visual-fill ()
(setq visual-fill-column-width 150
visual-fill-column-center-text t
visual-fill-column-enable-sensible-window-split t
;; header-line-format ""
)
(visual-fill-column-mode 1))
(use-package visual-fill-column
:hook (org-mode . ads/org-mode-visual-fill))
(with-eval-after-load 'org
(org-babel-do-load-languages
'org-babel-load-languages
'((emacs-lisp . t)
(python . t))))
(setq org-confirm-babel-evaluate nil)
(setq org-babel-default-header-args:python
'((:results . "output")
))
(with-eval-after-load 'org
;; This is needed as of Org 9.2
(require 'org-tempo)
(add-to-list 'org-structure-template-alist '("sh" . "src shell\n"))
(add-to-list 'org-structure-template-alist '("el" . "src emacs-lisp\n"))
(add-to-list 'org-structure-template-alist '("py" . "src python\n"))
(add-to-list 'org-structure-template-alist '("ht" . "src html\n"))
(add-to-list 'org-structure-template-alist '("html" . "src html\n"))
(add-to-list 'org-structure-template-alist '("css" . "src css\n"))
(add-to-list 'org-structure-template-alist '("cc" . "src C\n"))
(add-to-list 'org-structure-template-alist '("cp" . "src C++\n"))
(add-to-list 'org-structure-template-alist '("cpp" . "src C++\n"))
(add-to-list 'org-structure-template-alist '("rs" . "src rust\n"))
(add-to-list 'org-structure-template-alist '("yaml" . "src yaml\n"))
(add-to-list 'org-structure-template-alist '("toml" . "src toml\n"))
(add-to-list 'org-structure-template-alist '("js" . "src js\n"))
(add-to-list 'org-structure-template-alist '("jj" . "src java\n"))
(add-to-list 'org-structure-template-alist '("sql" . "src sql\n"))
(add-to-list 'org-structure-template-alist '("sq" . "src sql\n"))
)
(use-package evil-org
:ensure t
:after org
:hook (org-mode . (lambda () evil-org-mode))
:config
(require 'evil-org-agenda)
(evil-org-agenda-set-keys))
(use-package org-cliplink)
(ads/leader-keys
"ok" '(org-cliplink :wk "org-cliplink")
)
(defun org-replace-link-by-link-description ()
"Replace an org link by its description or if empty its address"
(interactive)
(if (org-in-regexp org-link-bracket-re 1)
(save-excursion
(let ((remove (list (match-beginning 0) (match-end 0)))
(description
(if (match-end 2)
(org-match-string-no-properties 2)
(org-match-string-no-properties 1))))
(apply 'delete-region remove)
(insert description)))))
This package seems like a godsend, I do need to spend some time looking into it. Org-transclusion User Manual
(use-package org-transclusion
:after org
;; :init
)
Same thing as the insert screenshot but works faster and can use with Win-S from clipboard
(defun ads/org-clip-image ()
"Take a screenshot into a time stamped unique-named file in the
same directory as the org-buffer and insert a link to this file."
(interactive)
(setq temp-image-filename
(make-temp-file
(concat
(file-relative-name buffer-file-name)
"_"
(format-time-string "%Y%m%d_%H%M%S_"))
nil
".png"))
(shell-command (concat
"powershell -command \"Add-Type -AssemblyName System.Windows.Forms;"
"if ($([System.Windows.Forms.Clipboard]::ContainsImage())) {$image = [System.Windows.Forms.Clipboard]::GetImage();[System.Drawing.Bitmap]$image.Save('"
temp-image-filename
"',[System.Drawing.Imaging.ImageFormat]::Png); Write-Output 'clipboard content saved as file'} else {Write-Output 'clipboard does not contain image data'}\""))
(org-attach-attach
temp-image-filename
nil
`mv)
(insert (concat
"[[file:"
(org-attach-dir)
"/"
(file-name-nondirectory temp-image-filename)
"]]"))
(org-display-inline-images))
(ads/leader-keys
"s" '(ads/org-clip-image :wk "org-insert-clipboard-image")
)
(defun ads/org-find-file ()
"Find file in ads/user-dir-org"
(interactive)
(counsel-find-file ads/user-dir-org)
)
(ads/leader-keys "f" '(ads/org-find-file :wk "Org Find File"))
(add-hook 'org-ctrl-c-ctrl-c-hook 'evil-normal-state)
(defun ads/org-checkbox-next ()
(interactive)
(when (org-at-item-checkbox-p)
(org-toggle-checkbox)
(re-search-forward "\\[ \\]")
(evil-normal-state))
)
;; (add-hook 'org-ctrl-c-ctrl-c-hook 'ads/org-checkbox-next)
(use-package async
:config
(defun ads/init-hook ()
"If the current buffer is 'readme.org' the code-blocks
are tangled."
(when (string= buffer-file-truename ads/user-dir-readme)
(async-start
`(lambda ()
(require 'org)
(let ((org-confirm-babel-evaluate nil)))
(org-babel-tangle-file ,ads/user-dir-readme))
(lambda (result)
(message "Tangled file compiled.")))))
(add-hook 'after-save-hook 'ads/init-hook))
;; (use-package dired-async
;; :after async
;; :config
;; (dired-async-mode 1))
(defun ads/new-org-note ()
(interactive)
(setq input (read-string "Enter new Filename:\t"))
;; (setq input "test file NaMe")
(setq input (replace-regexp-in-string "\s" "-" input))
(setq input (downcase input))
(setq input (concat ads/user-dir-org input ".org"))
(find-file input)
(evil-insert-state)
)
(ads/leader-keys
"on" '(ads/new-org-note :wk "new-org-note")
)
leader C-s
Open and go to scratch.org
(ads/leader-keys
"C-s" '(lambda () (interactive) (
find-file (concat ads/user-dir-org "scratch.org"))
:wk "ORG Config")
)
(add-to-list 'auto-mode-alist '("\\.keymap\\'" . c-or-c++-mode))
(use-package projectile
:diminish projectile-mode
:config (projectile-mode)
:custom ((projectile-completion-system 'ivy))
:bind-keymap
("C-c p" . projectile-command-map)
:init
(when (file-directory-p "c:/Users/Adrian/Documents/GitHub/")
;; Specify folder where you keep your coding projects
(setq projectile-project-search-path '("c:/Users/Adrian/Documents/GitHub/")))
(setq projectile-switch-project-action #'projectile-dired))
(use-package counsel-projectile
:after projectile
:config (counsel-projectile-mode))
Painful and super slow on windows, a large reason why I often use the <leader> git commands defined later
(use-package magit
:commands magit-status
;; display the diff from git in the same window (may be worth trying different options as well
:custom
(magit-display-buffer-function #'magit-display-buffer-same-window-except-diff-v1))
;(use-package evil-magit
; :after magit)
(global-set-key (kbd "C-c g") 'magit-file-dispatch)
(global-set-key (kbd "C-c C-g") 'magit-file-dispatch)
(global-set-key (kbd "C-x C-g") 'magit-status)
(defun magit-diff-paths-buffer-file (a)
"Show changes between buffer file and another file on disk"
(interactive (list (read-file-name "File to compare" nil nil t)
))
(message a)
(magit-diff-setup-buffer nil "--no-index"
nil (list (magit-convert-filename-for-git
(expand-file-name a))
(magit-convert-filename-for-git
(expand-file-name buffer-file-name))))
)
Windows commands for git becaue magit is almost unusably slow due to windows issues
(defun ads/git-stage ()
(interactive)
(save-buffer)
(shell-command (concat "git stage " buffer-file-name) )
(message
(concat "Staging file : " buffer-file-name)))
(ads/leader-keys
"gs"'(ads/git-stage :wk "git stage file"))
(defun ads/git-stage-all ()
(interactive)
(shell-command "git stage --all")
(message
(concat "Staging all changed files in: " (file-name-directory buffer-file-name))))
(ads/leader-keys
"gS"'(ads/git-stage-all :wk "git stage all"))
(defun ads/git-commit-file ()
(interactive)
(save-buffer)
(shell-command (concat "git stage " buffer-file-name) )
(magit-diff-staged)
(shell-command (concat "git commit -m \"" (read-string "Commit Message:\t") "\""))
(magit-mode-bury-buffer))
(ads/leader-keys
"gk"'(ads/git-commit-file :wk "git commit"))
git lazy
(defun ads/git-stage-commit-push ()
(interactive)
(save-buffer)
(shell-command (concat "git stage " buffer-file-name) )
(magit-diff-staged)
(delete-other-windows)
(shell-command (concat "git commit -m \"" (read-string "Commit Message:\t") "\""))
;; (message
;; (concat "Pushing Upstream: " (file-name-directory buffer-file-name)))
(async-shell-command "git push")
(magit-mode-bury-buffer))
(ads/leader-keys
; gl - Git Lazy
"gl"'(ads/git-stage-commit-push :wk "git commit"))
git lazy
(defun ads/git-stage-commit-amend-push ()
(interactive)
(save-buffer)
(message "Adding changes to last commit")
(async-shell-command
(concat "git stage " buffer-file-name
"&& git commit --amend --no-edit"
"&& git push -f")))
(ads/leader-keys
; go - Git Oops
"go"'(ads/git-stage-commit-amend-push :wk "git commit"))
(defun ads/git-commit-all ()
(interactive)
(magit-diff-staged)
(shell-command (concat "git commit -am \"" (read-string "Commit Message:\t") "\""))
(magit-mode-bury-buffer))
(ads/leader-keys
"gK"'(ads/git-commit-all :wk "git commit all"))
(defun ads/git-push ()
(interactive)
(message
(concat "Pushing Upstream: " (file-name-directory buffer-file-name)))
(async-start
(message
(shell-command-to-string
(concat
"cd "
(file-name-directory buffer-file-name)
" && git push ")))
(message "done")))
(ads/leader-keys
"gp"'(ads/git-push :wk "git push"))
(defun ads/git-pull ()
(interactive)
(message
(concat "Pulling from Upstream: " (file-name-directory buffer-file-name)))
(async-start
(message
(shell-command-to-string
(concat
"cd "
(file-name-directory buffer-file-name)
" && git pull ")))
(message "done")))
(ads/leader-keys
"gP"'(ads/git-pull :wk "git pull"))
(defun ads/git-fetch ()
(interactive)
(shell-command "git fetch --all")
(message
(concat "Fetching Upstream" (file-name-directory buffer-file-name))))
(ads/leader-keys
"gf"'(ads/git-fetch :wk "git fetch"))
(defun ads/git-restore-file ()
(interactive)
(shell-command (concat "git restore " buffer-file-name) )
(message
(concat "Restoring file: " buffer-file-name))
(revert-buffer))
(ads/leader-keys
"gr"'(ads/git-restore-file :wk "git restore file"))
Inspiration taken from GitHub - mcraveiro/cunene: My dot emacs, most of this will probably go away once I update to EMACS 28 and can use ligatures
(defun ads/prog-mode-configure-prettify-symbols-alist ()
"Set prettify symbols alist."
(setq prettify-symbols-alist '(("lambda" . "λ")
("->" . "→")
("->>" . "↠")
("=>" . "⇒")
("map" . "↦")
("/=" . "≠")
("!=" . "≠")
("==" . "≡")
("<=" . "≤")
(">=" . "≥")
("=<<" . "=≪")
(">>=" . "≫=")
("<=<" . "↢")
(">=>" . "↣")
("&&" . "∧")
("||" . "∨")
("not" . "¬")))
(prettify-symbols-mode))
(add-hook 'prog-mode-hook 'ads/prog-mode-configure-prettify-symbols-alist)
(use-package protobuf-mode)
(use-package anki-connect)
(use-package anki-editor
:after org
;; :bind (:map org-mode-map
;; ("<f12>" . anki-editor-cloze-region-auto-incr)
;; ("<f11>" . anki-editor-cloze-region-dont-incr)
;; ("<f10>" . anki-editor-reset-cloze-number)
;; ("<f9>" . anki-editor-push-tree))
:hook (org-capture-after-finalize . anki-editor-reset-cloze-number) ; Reset cloze-number after each capture.
:config
(setq anki-editor-create-decks t ;; Allow anki-editor to create a new deck if it doesn't exist
anki-editor-org-tags-as-anki-tags t)
(defun anki-editor-cloze-region-auto-incr (&optional arg)
"Cloze region without hint and increase card number."
(interactive)
(anki-editor-cloze-region my-anki-editor-cloze-number "")
(setq my-anki-editor-cloze-number (1+ my-anki-editor-cloze-number))
(forward-sexp))
(defun anki-editor-cloze-region-dont-incr (&optional arg)
"Cloze region without hint using the previous card number."
(interactive)
(anki-editor-cloze-region (1- my-anki-editor-cloze-number) "")
(forward-sexp))
(defun anki-editor-reset-cloze-number (&optional arg)
"Reset cloze number to ARG or 1"
(interactive)
(setq my-anki-editor-cloze-number (or arg 1)))
(defun anki-editor-push-tree ()
"Push all notes under a tree."
(interactive)
(anki-editor-push-notes '(4))
(anki-editor-reset-cloze-number))
;; Initialize
(anki-editor-reset-cloze-number)
)
(use-package ox-hugo :ensure t ;Auto-install the package from Melpa :pin melpa ;`package-archives’ should already have (“melpa” . “https://melpa.org/packages/”) :after ox (setq org-hugo-base-dir “~/git/hugo-site/content/” ) )
(use-package dired
:ensure nil
:commands (dired dired-jump)
:bind (("C-x C-j" . dired-jump))
:custom ((dired-listing-switches "-agho --group-directories-first"))
:hook (dired-mode . dired-hide-details-mode)
:config
(evil-collection-define-key 'normal 'dired-mode-map
"h" 'dired-single-up-directory
"l" 'dired-single-buffer)
(evil-global-set-key 'normal (kbd "C-x C-d") 'dired)
(setq delete-by-moving-to-trash t)
(setq-default dired-hide-details-mode t)
(setq dired-kill-when-opening-new-dired-buffer t))
;;(use-package dired-single
;; :commands (dired dired-jump))
(use-package dired-git-info
:ensure t
;:hook (dired-mode . (local-set-key ")" 'dired-git-info-mode))
:bind (:map dired-mode-map (")" . dired-git-info-mode)))
(use-package diredfl
:ensure t
:config
(diredfl-global-mode 1))
;(use-package dired-open
; :commands (dired dired-jump)
; :config
; ;; Doesn't work as expected!
; ;;(add-to-list 'dired-open-functions #'dired-open-xdg t)
; (setq dired-open-extensions '(("pdf" . "feh")
;; ("mkv" . "mpv"))))
(setq counsel-find-file-extern-extensions
'("xlsx"
"xls"
"mkv"
"mp4"
"pdf"
"doc"
"docx"
"ppt"
"pptx"
"wmv"
"mp3"))
(prefer-coding-system 'utf-8)
(set-default-coding-systems 'utf-8)
(set-terminal-coding-system 'utf-8)
(set-keyboard-coding-system 'utf-8)
(when (display-graphic-p)
(setq x-select-request-type '(UTF8_STRING COMPOUND_TEXT TEXT STRING)))
(use-package treemacs
:ensure t
:defer t
;; :init
:config
(progn
(setq
treemacs-file-event-delay 1000
treemacs-file-follow-delay 0.1
treemacs-follow-after-init nil
treemacs-expand-after-init nil
treemacs-indentation 1
treemacs-missing-project-action 'remove
treemacs-persist-file (if (string= ads/computer-id "work")
"c:/users/adanaos/git/emacs-work/treemacs-persist"
(expand-file-name ".cache/treemacs-persist" user-emacs-directory))
treemacs-width 30)
(treemacs-resize-icons 15) ; Smaller icons
(treemacs-filewatch-mode t )
(treemacs-fringe-indicator-mode t )
(treemacs-fringe-indicator-mode 'always )
(pcase (cons (not (null (executable-find "git")))
(not (null treemacs-python-executable)))
(`(t . t)
(treemacs-git-mode 'deferred))
(`(t . _)
(treemacs-git-mode 'simple))))
(define-key treemacs-mode-map (kbd "C-c C-p C-a") 'treemacs-add-project-to-workspace)
(define-key treemacs-mode-map (kbd "C-c C-p C-d") 'treemacs-remove-project-from-workspace)
(define-key treemacs-mode-map (kbd "C-SPC C-t") 'treemacs-quit)
)
(use-package treemacs-evil
:after treemacs evil
:ensure t)
(use-package treemacs-projectile
:after treemacs projectile
:ensure t)
(use-package treemacs-icons-dired
:after treemacs dired
:ensure t
:config (treemacs-icons-dired-mode))
(use-package treemacs-magit
:after treemacs magit
:ensure t)
(use-package treemacs-persp
:after treemacs persp-mode
:ensure t
:config (treemacs-set-scope-type 'Perspectives))
(ads/leader-keys
"C-t" '(treemacs :wk "treemacs"))
(defun treemacs-laptop-mode-toggle ()
(interactive)
(if treemacs-laptop-mode-status
(treemacs-laptop-mode-off)
(treemacs-laptop-mode-on)
)
;; (setq treemacs-laptop-mode-status (not ads/treemacs-laptop-mode-status))
)
(defun treemacs-laptop-mode-on ()
(interactive)
(setq treemacs-laptop-mode-status t)
(setq treemacs-width 25
treemacs-indentation 1
treemacs-default-visit-action 'treemacs-visit-node-close-treemacs )
(message "treemacs-laptop-mode-on")
)
(defun treemacs-laptop-mode-off ()
(interactive)
(setq treemacs-laptop-mode-status nil)
(setq treemacs-width 35
treemacs-indentation 2
treemacs-default-visit-action 'treemacs-visit-node-no-split
)
(message "treemacs-laptop-mode-off")
)
;; (if (> (frame-width) 200)
;; (treemacs-laptop-mode-off)
;; (treemacs-laptop-mode-on)
;; )
;; (print ads/treemacs-laptop-mode-status)
(display-monitor-attributes-list)
(if (> (frame-width) 200)
(setq treemacs-laptop-mode-status nil)
(setq treemacs-laptop-mode-status t)
)
(print treemacs-laptop-mode-status)
Load my
deimos
config stuff
(when
(string= system-name "deimos")
(org-babel-load-file (concat ads/user-dir-emacs "linux.org"))
(org-babel-load-file (concat ads/user-dir-org "python-development-setup.org")
))
(load-file (concat ads/user-dir-org "work.el"))
Automatically tangle my configuration files. Since I have multiple ones for individual computers that I have to use which may need different configuration settings.
(setq org-babel-auto-tangle-file-list
(list
"c:/Users/adanaos/git/emacs-new/emacs.org"
))
(defun org-babel-auto-tangle-files ()
;; Automatically tangle files in ~org-babel-auto-tangle-file-list~ when one of them is saved
(when (member buffer-file-name org-babel-auto-tangle-file-list)
(org-babel-tangle-file buffer-file-name)))
Add hook to after save hook when on org mode
(add-hook 'org-mode-hook
(lambda () (add-hook 'after-save-hook 'org-babel-auto-tangle-files)))
;; (setq debug-on-error nil)