Skip to content

avkoval/emacs.d

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

10 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Alex V Koval (avkoval) emacs configuration file

Basic keybindings

Free some keybindings

The typical strategy of using emacs - reconfigure shortcuts to the applications you mostly use. This is very individual thing, as things which typical JS developer differ for things of Python developer, and the difference is much bigger between develpers, and for example, text writers.

Here I free some key bindings and allow to use them later for various packages.

(global-unset-key (kbd "C-z"))
(global-unset-key (kbd "C-z j"))
(global-unset-key (kbd "C-x C-j"))
(global-unset-key [f9])
(global-unset-key [(control \#)])

Packages configuration

Package sources

Custom package sources. Also I’ve read somewhere that emacs default TLS configuration is not ideal and reconfigured it according the recipe.

 (package-initialize)
 (unless (assoc-default "melpa" package-archives)
   (add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t))
 (unless (assoc-default "gnu" package-archives)
   (add-to-list 'package-archives '("gnu" . "https://elpa.gnu.org/packages/") t))
 (unless (assoc-default "ox-odt" package-archives)
   (add-to-list 'package-archives '("ox-odt" . "https://kjambunathan.github.io/elpa/") t))

 (setq tls-program
	   '("gnutls-cli --x509cafile /etc/ssl/certs/ca-certificates.crt -p %p %h"
	     "gnutls-cli --x509cafile /etc/ssl/certs/ca-certificates.crt -p %p %h --protocols ssl3"
	     "openssl s_client -connect %h:%p -CAfile /etc/ssl/certs/ca-certificates.crt -no_ssl2 -ign_eof"))

Use-package

There are several (to package.el) alternative/additional package managers, I use use-package.

     (setq use-package-always-ensure t)

     (unless (package-installed-p 'use-package)
	 (package-refresh-contents)
	 (package-install 'use-package))
     (setq use-package-verbose t)
     (setq use-package-always-ensure t)
     (eval-when-compile
	 (require 'use-package))
     (use-package auto-compile
	 :config (auto-compile-on-load-mode))

Helm

Helm is one of the shining packages of Emacs - it does one thing, and does it well - it allows you to choose something from a long list of candidates.

It does have some criticism, for example it does not follow Emacs conventions on setting colors, as result many themes are not very compatible and will show wierd colors.

(use-package helm
  :diminish helm-mode
  :init
  (progn
    ;; (require 'helm-config)

    ;; (setq )
    ;; From https://gist.github.com/antifuchs/9238468
    (setq helm-M-x-requires-pattern nil
          ;; helm-display-function 'helm-display-buffer-in-own-frame
          helm-autoresize-max-height 50
          helm-autoresize-min-height 3
          helm-autoresize-mode t
          helm-buffer-max-length 40
          helm-buffer-skip-remote-checking t
          helm-candidate-number-limit 100
          helm-candidate-number-limit 20000
          helm-debug-root-directory "/home/k/tmp/helm/"
          helm-display-buffer-reuse-frame nil
          helm-display-header-line nil
          helm-display-source-at-screen-top nil
          helm-ff-keep-cached-candidates nil
          helm-ff-skip-boring-files t
          helm-file-globstar nil
          helm-findutils-search-full-path t
          helm-full-frame nil
          helm-idle-delay 0.0 ; update fast sources immediately (doesn't).
          helm-input-idle-delay 0.01  ; this actually updates things
          helm-input-idle-delay 0.1
          helm-org-headings-fontify nil
          helm-org-headings-max-depth 30
          helm-org-rifle-show-path t
          helm-org-show-filename t
          helm-org-truncate-lines nil
          helm-quick-update t
          helm-split-window-default-side 'right
          helm-use-undecorated-frame-option nil
          helm-yas-display-key-on-candidate t
          hmelm-org-format-outline-path t
          ))
  :config
  (progn
 (require 'helm-files)
    ;; This is slightly different from defaults because I am using emacs with i3 and clipmon
    ;; and pass and so now I reach good security settings along with copy/paste history for\
    ;; both emacs and other desktop apps
    (setq
     helm-kill-ring-actions
     '(("Copy to clipboard" . kill-new)
       ("Yank marked" . helm-kill-ring-action-yank)
       ("Delete marked" . helm-kill-ring-action-delete)))

    (custom-set-variables
     '(helm-firefox-show-structure t t)
     '(helm-idle-delay 0.2 t)
     )
    ;; (helm-mode) - I don't enable global helm-mode
    ; (define-key helm-find-files-map [(control tab)] 'helm-buffers-list)
    (define-key helm-map (kbd "C-z") 'helm-select-action)
    (define-key helm-map (kbd "<tab>")         'helm-execute-persistent-action)
    (define-key helm-find-files-map (kbd "C-<backspace>") 'helm-find-files-up-one-level)
    (require 'savehist)
    (add-to-list 'savehist-additional-variables 'helm-dired-history-variable)
   (savehist-mode 1))

  :bind (("C-z C-r" . helm-recentf)
         ([M-f3] . helm-find-files)
         ("C-z C-f" . helm-find-files)
         ([M-f9] . helm-mark-ring)
         ("s-x" . helm-M-x)
         ("<mouse-9>" . helm-imenu)
         ("\C-c v" . helm-imenu)
         ;;           ("C-x /" . helm-surfraw)
         ([(s-tab)] . helm-buffers-list)
         ("C-z C-b" . helm-buffers-list)
         ("C-z C-a" . helm-mini)
         ("C-z C-r" . helm-recentf)
         ([f4] . helm-recentf)
         ("C-z C-f" . helm-find-files)
         ("C-z f f" . helm-etags-select)
         ("C-c h m" . helm-mark-ring)
         ("C-c h r" . helm-resume)
         ("C-c h t" . helm-top)
         ([M-f12] . helm-resume)
         ("C-z H" . helm-org-in-buffer-headings)
         ("C-z o" . helm-occur)
         ([C-f2] . helm-bookmarks)
         )
  )
(global-set-key (kbd "<f2>")  'helm-imenu)

(ido-mode -1) ;; Turn off ido mode in case I enabled it accidentally
;; (require 'helm-mode)

(define-key org-mode-map (kbd "C-s-<tab>") 'helm-buffers-list)

helm-comint

(use-package helm-comint
  :bind
  (("C-c h h" . helm-comint-input-ring)))

helm-fzf

(use-package s)
(use-package dash)
(require 'helm-fzf)

helm-ag

Searching using β€œThe silver searcher” with Helm.

(use-package helm-ag
  :init
  :config
(progn
     (setq helm-ag-base-command "ag --nocolor --nogroup")
    )
(setq org-log-done 'time)
  :bind (
         ("C-c h s g" . helm-ag)
         ("C-c s" . helm-projectile-ag)
         ([f7] . helm-projectile-ag)
         ))

helm-pass

Password management using famous β€˜pass’ utility. If you never tried it, it is much better then many of other password managers available, including most of commercial.

(use-package helm-pass
  :init
  :bind (("C-z p s" . helm-pass)))

This module provides searhing, but it also has dependency module for generic pass management within emacs UI.

helm-org

(use-package helm-org)

helm-rg

(use-package helm-rg
  :init
  :config
  (progn
    ;;             (setq helm-ag-base-command "rg --no-heading")
    (setq helm-ag-base-command "ag --nocolor --nogroup")
    )
  (setq org-log-done 'time)
  :bind (("C-c h s r" . helm-rg)
	    ("C-c h s R" . helm-projectile-rg)
	    ))

helm-org-roam

 (defun helm-org-roam (&optional input candidates)
   (interactive)
   (require 'org-roam)
   (helm
    :input input
    :sources (list
		(helm-build-sync-source "Roam: "
		  :must-match nil
		  :fuzzy-match t
		  :candidates (or candidates (org-roam--get-titles))
		  :action
		  '(("Find File" . (lambda (x)
				     (--> x
					  org-roam-node-from-title-or-alias
					  (org-roam-node-visit it t))))
		    ("Insert link" . (lambda (x)
				       (--> x
					    org-roam-node-from-title-or-alias
					    (insert
					     (format
					      "[[id:%s][%s]]"
					      (org-roam-node-id it)
					      (org-roam-node-title it))))))
		    ("Follow backlinks" . (lambda (x)
					    (let ((candidates
						   (--> x
							org-roam-node-from-title-or-alias
							org-roam-backlinks-get
							(--map
							 (org-roam-node-title
							  (org-roam-backlink-source-node it))
							 it))))
					      (helm-org-roam nil (or candidates (list x))))))))
		(helm-build-dummy-source
		    "Create note"
		  :action '(("Capture note" . (lambda (candidate)
						(org-roam-capture-
						 :node (org-roam-node-create :title candidate)
						 :props '(:finalize find-file)))))))))

 (defalias 'escalator-helm-org-roam 'helm-org-roam)
 ;;	   ("C-c f r" . helm-org-roam))
 (global-set-key (kbd "C-C f r ") 'helm-org-roam)

Choose/Change font

I wrote function to choose font using Helm.

(require 'subr-x)

(defcustom my-frame-default-font "" "Default font used for fontify new frames")

(unless (boundp 'helm-xfonts-cache)
  (defvar helm-xfonts-cache nil))

(defun fontify-frame (frame)
  (unless (= (length my-frame-default-font) 0)
    (set-frame-parameter frame 'font my-frame-default-font))
  )

(fontify-frame nil)
(push 'fontify-frame after-make-frame-functions)

(defun change_font (new-font where &optional size)
  (interactive)
  (let
      ((font-with-size (split-string new-font "-"))
       (size (or size (read-from-minibuffer "Font size: " "14"))))
    (setcar (nthcdr 7 font-with-size) size)
    (let ((new-font-final (string-join font-with-size "-")))
      (if (string= where "default")
          (progn
            (set-face-font 'default new-font-final)
            (setq my-frame-default-font new-font-final))
        (set-frame-parameter nil 'font new-font-final))
      )
    (message (format "Default font set to %s of size %s" new-font size))
    (setq org-ellipsis "‡")
    ))

(defun my-fix-org ()
  (interactive)
  (setq org-ellipsis "‡"))

;; (defun my-set-default-font()
;;   (interactive)
;;   (set-face-font 'default my-frame-default-font)
;;   (set-frame-parameter nil 'font my-frame-default-font)
;;   )

;; (advice-add 'my-set-default-font :after 'customize-themes)

(defvar avk-change-default-font18
  (helm-build-sync-source "AVK font selection"
    :init (lambda ()
            (unless helm-xfonts-cache
              (setq helm-xfonts-cache
                    (x-list-fonts "*")))
            )
    :candidates 'helm-xfonts-cache
    :action '(("Set default font" . (lambda (new-font)
                                      (kill-new new-font)
                                      (change_font new-font "default")
                                      ))
              ("Set current frame font" . (lambda (new-font)
                                            (kill-new new-font)
                                            (change_font new-font "frame")
                                            ))
              )
    :persistent-action (lambda (new-font)
                         (set-frame-font new-font 'keep-size)
                         (kill-new new-font))
    :persistent-help "Preview font and copy to kill-ring"))

(defun avk-change-default-font-fn ()
  (interactive)
  (helm :sources '(avk-change-default-font18))
  )

(define-key global-map (kbd "C-z f a") 'avk-change-default-font-fn)

                                        ; this theme needs explicit require ?

;; emoji
(set-fontset-font "fontset-default" '(#x1F300 . #x1F55F) (font-spec :size 20 :name "Unifont Upper"))

Ahg (mercurial support)

I love Mercurial (over git) and I will never understand and agree that git is won the version control competition game. I still use it for personal projects despite the declining support everywhere.

(use-package ahg)
(global-set-key (kbd "C-z h") 'ahg-status)
(global-set-key (kbd "C-<f4>") 'ahg-status)

Dash

A modern list library for Emacs. Its just required to be installed of the many packages as a dependency.

(use-package dash)

Unique file names (β€˜uniquify)

(require 'uniquify)
(custom-set-variables
 '(uniquify-buffer-name-style (quote post-forward) nil (uniquify)))

Hydra

https://github.com/abo-abo/hydra - make Emacs bindings that stick around

This is a package for GNU Emacs that can be used to tie related commands into a family of short bindings with a common prefix - a Hydra.

(use-package hydra)

And now some various hydras

M-s

Hydra for highlights.

(defun copy-current-buffer-name()
  (interactive)
  (kill-new (buffer-name))
  )
(defhydra alt_s_hydras_menu (:columns 2 :exit t)
  "M-s menu"

  ("." isearch-forward-symbol-at-point "Isearch symbol at point")
  ("_" isearch-forward-symbol "Do incremental search forward for a symbol")
  ("o" occur "Show occurencies")
  ("f" copy-current-buffer-name "Remember current buffer name")
  ("w" isearch-forward-word "Isearch forward word")
  ("h." highlight-symbol-at-point "Highlight symbol at point")
  ("hl" highlight-lines-matching-regexp "Highlight lines matcing RegExp")
  ("hp" highlight-phrase "Highlight phrase")
  ("hr" highlight-regexp "Highlight RegExp")
  ("hu" unhighlight-regexp "Unhighlight RegExp")
  ("hw" hi-lock-write-interactive-patterns "Write interactive patterns")
  ("M-w" eww-search-words "Search the web for the text")
  )
(global-set-key "\M-s" 'alt_s_hydras_menu/body)

Backups

This is one of the things people usually want to change right away. By default, Emacs saves backup files in the current directory. These are the files ending in ~ that are cluttering up your directory lists. The following code stashes them all in ~/.emacs.d/backups, where I can find them with C-x C-f (find-file) if I really need to.

///#+BEGIN_SRC emacs-lisp :results output none //;; (setq backup-directory-alist β€˜((β€œ.” . β€œ~/.emacs.d/backup”))) //#+END_SRC

Disk space is cheap. Save lots.

 (setq delete-old-versions nil
	  kept-new-versions 100
	  kept-old-versions 100
	  version-control t)
 (setq version-control t)
 (setq vc-make-backup-files t)
 ;;(setq auto-save-file-name-transforms '((".*" "~/.emacs.d/auto-save-list/" t)))

Disable tool-bar

Disable tool-bar

(tool-bar-mode -1)

org-html export

from: https://emacs.stackexchange.com/questions/3374/set-the-background-of-org-exported-code-blocks-according-to-theme

(defun my/org-inline-css-hook (exporter)
  "Insert custom inline css to automatically set the
background of code to whatever theme I'm using's background"
  (when (eq exporter 'html)
    (let* ((my-pre-bg (face-background 'default))
           (my-pre-fg (face-foreground 'default)))
      (setq
       org-html-head-extra
       (concat
        org-html-head-extra
        (format "<style type=\"text/css\">\n pre.src {background-color: %s; color: %s;}</style>\n"
                my-pre-bg my-pre-fg))))))

;; FIXME
;; (add-hook 'org-export-before-processing-hook 'my/org-inline-css-hook)

org-mode

embed images into export

(defun replace-prefix-if-present (string prefix new-prefix)
  "If STRING starts with PREFIX, replace the PREFIX by NEW-PREFIX.
   Else, returns NIL."
  (if (string-prefix-p prefix string)
      (concat new-prefix (substring string (length prefix)))
    string))

;; (defun replace-in-string (what with in)
;;   (replace-regexp-in-string (regexp-quote what) with in nil 'literal))

(defun org-org-html--format-image (source attributes info)
  (format "<img src=\"data:image/%s+xml;base64,%s\"%s />"
          (or (file-name-extension source) "")
          (base64-encode-string
           (with-temp-buffer
             (insert-file-contents-literally (replace-prefix-if-present source "file://" ""))
             (buffer-string)))
          (file-name-nondirectory source)))
(advice-add #'org-html--format-image :override #'org-org-html--format-image)

ellipsis

(setq org-ellipsis "‡")

ox-publish (my blog)

(require 'ox-publish)
(setq org-html-validation-link nil)
(setq org-publish-project-alist
      '(
        ("avk-articles"
         :base-directory "~/dev/koval.kharkov.ua/org-publish/"
         :base-extension "org"
         :publishing-directory "~/public_html/"
         :recursive t
         :publishing-function org-html-publish-to-html
         :headline-levels 4             ; Just the default for this project.
         :auto-sitemap t
         :auto-preamble t
         :sitemap-title "All Blog Posts"
         :sitemap-filename "posts.org"
         :sitemap-style list
         :author "Oleksii (Alex) Koval"
         :email "alex@koval.kharkov.ua"
         :with-creator t
         :section-numbers      nil
         :with-author          nil
         :with-date            t
         :with-title           t
         :with-toc             nil
         :html-preamble "<a href=\"/\">home</a>This is just a test"
        )
      ("avk-static"
       :base-directory "~/dev/koval.kharkov.ua/org-publish/"
       :base-extension "css\\|js\\|png\\|jpg\\|gif\\|pdf\\|mp3\\|ogg\\|swf"
       :publishing-directory "~/public_html/"
       :recursive t
       :publishing-function org-publish-attachment
       )
      ("avk-site" :components ("avk-articles" "avk-static")))
)

ox-moderncv

(use-package ox-moderncv
    :load-path "~/.emacs.d/lisp/org-cv/"
    :init (require 'ox-moderncv))

ox-hugo

(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)

ob-mongo

(use-package ob-mongo)

ob-clojure

(require 'ob-clojure)
(setq org-babel-clojure-backend 'cider)
(require 'cider)

main settings

https://orgmode.org/manual/Structure-Templates.html

  ;; Org-mode settings
  (add-to-list 'load-path "/usr/share/emacs/site-lisp/org")
                                          ;(add-to-list 'load-path "~/.emacs.d/lisp/ob-async")
  ;;(require 'org-checklist)
  (require 'org-tempo)

  (when (featurep 'notmuch)
    (require 'org-notmuch)
    )

  ;; to store links from eww
                                          ; (require 'org-eww)
  (use-package ob-http)
                                          ;(require 'org-bullets) - they slow down emacs org mode
  (add-to-list 'load-path "~/.emacs.d/lisp/ob-async")
  (use-package ob-async)
  (use-package restclient)
  (use-package ob-restclient)
  (use-package org-rich-yank)
  (require 'ox-beamer)

  (org-babel-do-load-languages
   'org-babel-load-languages
   '((shell . t)
     ;;      (plantuml . t)
     (lisp . t)
     (clojure . t)
     (python . t)
     (dot . t)
     (awk . t)
     (emacs-lisp . t)
     (verb . t)
     (sql . t)
     )
   )

  ;; optional exporters
  (with-eval-after-load 'ox
    (require 'ox-latex)
    (loop for pkg in '(ox-gfm ox-pandoc ox-reveal ox-confluence ox-md ox-jira ox-textile ox-html5slide ox-ioslide)
          do (unless (require pkg nil 'noerror)
               (message (format "You need to install package %s" pkg))))
    )

  (use-package ox-pandoc)

  (require 'org-clock)
  (setq org-replace-disputed-keys t)
  (setq org-disputed-keys (quote (([(shift up)] . [(control c)(up)]) ([(shift down)] . [(control c)(down)]) ([(shift left)] . [(control c)(left)]) ([(shift right)] . [(control c)(right)]) ([(control shift right)] . [(meta shift +)]) ([(control shift left)] . [(meta shift _)]))))


  (add-to-list 'auto-mode-alist '("\\.org$" . org-mode))
  (global-set-key "\C-cls" 'org-store-link)
  (global-set-key "\C-ca" 'org-agenda)

  (fset 'goto-org-agenda
        "\C-caa")


  (global-set-key [XF86HomePage] 'goto-org-agenda)


  (global-set-key [(shift f5)]  'org-clock-goto)
  (global-set-key "\C-c\C-x\C-j"  'org-clock-goto)
  (global-set-key "\C-z`" 'org-clock-in)
  (global-set-key "\C-z~" 'org-clock-out)
  (fset 'my-clock-in-current-task
        (lambda (&optional arg) "Keyboard macro." (interactive "p") (kmacro-exec-ring-item '("οΏ½οΏ½`1" 0 "%d") arg)))
  (global-set-key "\C-z1" 'my-clock-in-current-task)

  (global-set-key [(control f5)] 'org-clock-in)
  (global-set-key [(control shift f5)] 'org-clock-out)


  (global-font-lock-mode 1)

  ;; temp disabled
  ;; (defun my-org-mode-hook ()
  ;;   (local-set-key [(meta tab)] 'ido-switch-buffer)
  ;;   (local-set-key (kbd "C-z r g") 'org-redmine-get-issue)
  ;;   (yas-minor-mode)
  ;;   ;(org-bullets-mode 1)
  ;;   )
  ;; (add-hook 'org-mode-hook 'my-org-mode-hook)

  (setq org-src-fontify-natively t)
  (setq org-capture-bookmark nil) ;; remove side effect  - bm face over the all new captured items!

  (setq org-directory "~/org/")

  (setq org-default-notes-file (concat org-directory "/notes.org"))
  (define-key global-map "\C-cc" 'org-capture)

  (defun org-todo-keyword-faces-dark()
    (interactive)
    (setq org-todo-keyword-faces
          '(
            ("IDEA" . (:foreground "chartreuse" :weight bold))
            ("WORKING" . (:foreground "forest green" :weight bold))
            ("DELEGATE" . (:foreground "deep sky blue" :background "#032251" :weight normal))
            ("DELEGATED" . (:foreground "LightSteelBlue" :background "#032251" :weight normal))
            ("REVIEW" . (:foreground "light coral" :background "#032251" :weight normal))
            ("FEEDBACK" . (:foreground "light coral" :background "#032251" :weight normal))
            ("TOPAIR" . (:foreground "wheat" :background "#1c4b78" :weight normal))
            ("ASSIGNED" . (:foreground "green yellow" :background "#032251" :weight normal))
            ("CANCELLED" . (:foreground "dark green" :background "gray17" :weight bold :strike-through "coral"))
            ("WORKSFORME" . (:foreground "dark green" :background "gray17" :weight bold :strike-through "coral"))
            )
          )
    )

  (defun switch-to-agenda() ()
         (interactive)
         (if (get-buffer "*Org Agenda*")
             (switch-to-buffer "*Org Agenda*")
           (org-agenda))
         )

  (fset 'switch-to-agenda-named-buffer
        (kmacro-lambda-form [?\C-x ?b ?* ?O ?r ?g ?  ?A ?g ?e ?n ?d ?a tab return] 0 "%d"))


  ;; (global-set-key (kbd "s-`") 'switch-to-agenda)
  (global-set-key (kbd "C-z C-q") 'switch-to-agenda-named-buffer)


  (setq org-completion-use-ido t)

  (defun org-todo-keyword-faces-light()
    (interactive)
    (setq org-todo-keyword-faces
          '(
            ("WORKING" . (:background "green yellow"))
            ("TODO" . (:foreground "DarkSlateBlue" :weight bold))
            ("DELEGATE" . (:foreground "black" :background "LightSeaGreen" :weight normal :slant italic))
            ("DELEGATED" . (:foreground "DarkSlateBlue" :weight bold :slant italic))
            ("REVIEW" . (:foreground "black" :background "LightGoldenrod" :weight normal :slant italic))
            ("TOPAIR" . (:foreground "black" :background "PaleTurquoise" :weight normal :slant italic))
            ("ASSIGNED" . (:foreground "black" :background "Yellow" :weight normal :slant italic))
            ("CANCELLED" . (:foreground "white" :background "dark red" :weight bold :strike-through "coral"))
            ("WORKSFORME" . (:foreground "white" :background "dark red" :weight bold :strike-through "coral"))
            )
          ))

  (defun insert-time-with-seconds ()
    (interactive)
    (insert (format-time-string "%H:%M.%S")))


  (global-set-key "\C-c0" 'insert-time-with-seconds)

  (custom-set-faces
   '(org-done ((t (:strike-through t)))))


  (defun my-org-insert-current-item-time()
    "Insert HH:MM into the buffer. Used during reporting of work done"
    (interactive)
    (let* (
           (clocked-time (org-clock-get-clocked-time))
           (h (/ clocked-time 60))
           (m (- clocked-time (* 60 h)))
           )
      (insert (format "%.2d:%.2d" h m))
      )
    )


  ;; (defun display-debug ()
  ;;   (interactive)
  ;;   (message (format "%.2f" org-clock-file-total-minutes))
  ;;   )
  (defun my-org-insert-item-report-line()
    "Interactive reporting during work done"
    (interactive)
    (insert-time-with-seconds)
    (insert " (")
    (my-org-insert-current-item-time)
    (insert ") ")
    )

  (global-set-key "\C-cit" 'my-org-insert-item-report-line)

  (setq org-global-properties
        '(("Effort_ALL". "1:00 2:00 3:00 5:00 8:00 16:00 0:10 0:15 0:30 0")))

  (setq org-columns-default-format
        "%40ITEM %5Effort(Estimated Effort){:} %8CLOCKSUM_T %TODO %3PRIORITY %TAGS")

  (add-hook 'org-clock-out-hook
            (lambda ()
              (fix-frame-title)))

                                          ; http://orgmode.org/worg/org-contrib/babel/languages/ob-doc-dot.html#sec-2

  (defun switch-to-orgfile(bufname)
    (if (get-buffer bufname)
        (switch-to-buffer bufname)
      (pop-to-buffer (find-file (concat "~/org/" bufname))))
    )

  (defun switch-to-labster()
    (interactive)
    (switch-to-orgfile "labster.org"))

  (defun switch-to-work()
    (interactive)
    (switch-to-orgfile "work.org"))

  (global-set-key "\C-z\C-l" 'switch-to-labster)
  (global-set-key "\C-z\C-w" 'switch-to-work)


  (global-set-key (kbd "C-z n") 'helm-org-agenda-files-headings)
  (define-key org-mode-map (kbd "C-z !") 'org-time-stamp-inactive)
  (define-key org-mode-map (kbd "C-C C-r") 'org-reveal)
  (define-key org-mode-map (kbd "C-x <insert>") 'org-meta-return)
  (define-key org-mode-map (kbd "C-c b") 'org-tree-to-indirect-buffer)

  (custom-set-variables
   '(markdown-command "/usr/bin/pandoc"))


  (defun sync-google-calendar ()
    "Save google calender entries into dairy.
  See more about this approach at https://www.youtube.com/watch?v=cIzzjSaq2N8&t=339s"
    (interactive)
    ;; (call-process "~/org/get_ical.py" nil 0 nil)
    (call-process "~/org/get_ical.py" nil nil)
    (switch-to-buffer "diary")
    (erase-buffer)
    (save-buffer)
    ;; (delete-file "~/.emacs.d/diary")
    (mapcar (
             lambda (icsfile)
             (icalendar-import-file icsfile "~/.emacs.d/diary")
             )
            (file-expand-wildcards "~/org/*.ics"))
    )

  ;;

  (defun copy-password-to-buffer()
    "Yank password property"
    (interactive)
    (let ((password (org-entry-get (point) "password")))
      (kill-new password)
      (gui-set-selection "PRIMARY" password)
      )
    )

  (define-key global-map (kbd "C-z p p") 'copy-password-to-buffer)

                                          ; https://emacs.stackexchange.com/questions/2952/display-errors-and-warnings-in-an-org-mode-code-block

                                          ; http://kitchingroup.cheme.cmu.edu/blog/2015/01/04/Redirecting-stderr-in-org-mode-shell-blocks/                                       ;
                                          ; (require 'async-org-babel)

                                          ; redisplay inline images inline in realtime?
  (add-hook 'org-babel-after-execute-hook 'org-redisplay-inline-images)


  (add-hook 'org-mode-hook #'yas-minor-mode)
  (defun org-plus-yasnippet()
    (setq-local yas-indent-line 'fixed))
  (add-hook 'org-mode-hook #'org-plus-yasnippet)

  (add-hook 'org-mode-hook (lambda ()
                             (visual-line-mode -1)))
  ;;

  (require 'ox-latex)
  (add-to-list 'org-latex-classes
               '("beamer"
                 "\\documentclass\[presentation\]\{beamer\}"
                 ("\\section\{%s\}" . "\\section*\{%s\}")
                 ("\\subsection\{%s\}" . "\\subsection*\{%s\}")
                 ("\\subsubsection\{%s\}" . "\\subsubsection*\{%s\}")))
  (setq org-latex-listings t)


  ;; https://github.com/unhammer/org-rich-yank
  (require 'org-rich-yank)
  (define-key org-mode-map (kbd "C-M-y") #'org-rich-yank)


(defun my-switch-to-compilation()
  (interactive)
  (if (get-buffer "*compilation*")
      (switch-to-buffer "*compilation*")
    )
  )
(define-key esc-map [f9] #'my-switch-to-compilation)


  ;; org speed keys
  ;; https://emacs.stackexchange.com/questions/33310/how-to-use-org-mode-speed-commands-speed-keys
  ;; https://notesyoujustmightwanttosave.blogspot.com/2011/12/org-speed-keys.html?showComment=1535219875417
  ;; (defun forward-and-preview ()
  ;;   "Go to same level next heading and show preview in dedicated buffer"
  ;;   (hide-subtree)
  ;;   (org-speed-move-safe (quote outline-next-visible-heading))
  ;;   (show-children)
  ;;   (org-tree-to-indirect-buffer)
  ;;   )
  ;; (defun back-and-preview ()
  ;;   "Go to same level previous heading and show preview in dedicated buffer"
  ;;   (hide-subtree)
  ;;   (org-speed-move-safe (quote outline-previous-visible-heading))
  ;;   (show-children)
  ;;   (org-tree-to-indirect-buffer)
  ;;   )
  ;; (defun up-back-and-preview ()
  ;;   "Go to previous level heading and show preview in dedicated buffer"
  ;;   (org-speed-move-safe (quote outline-up-heading))
  ;;   (org-tree-to-indirect-buffer)
  ;;   (hide-subtree)
  ;;   )
  ;; (defun up-forward-and-preview ()
  ;;   "Go to previous level next heading and show preview in dedicated buffer"
  ;;   (org-speed-move-safe (quote outline-up-heading))
  ;;   (hide-subtree)
  ;;   (org-speed-move-safe (quote outline-next-visible-heading))
  ;;   (org-tree-to-indirect-buffer)
  ;;   )
  ;; (defun inside-and-preview ()
  ;;   "Go to next level heading and show preview in dedicated buffer"
  ;;   (org-speed-move-safe (quote outline-next-visible-heading))
  ;;   (show-children)
  ;;   (org-tree-to-indirect-buffer)
  ;;   )
  ;; (add-to-list 'org-speed-commands-user '("l" inside-and-preview))
  ;; (add-to-list 'org-speed-commands-user '("j" forward-and-preview))
  ;; (add-to-list 'org-speed-commands-user '("k" back-and-preview))
  ;; (add-to-list 'org-speed-commands-user '("J" up-forward-and-preview))
  ;; (add-to-list 'org-speed-commands-user '("K" up-back-and-preview))

  (setq org-use-speed-commands t)

  ;; ;; (require 'org-sidebar)
  ;; ;;

  ;; ;; https:
  ;; //emacs.stackexchange.com/questions/7211/collapse-src-blocks-in-org-mode-by-default
  (defvar org-blocks-hidden nil)
  (defun org-toggle-blocks ()
    (interactive)
    (if org-blocks-hidden
        (org-show-block-all)
      (org-hide-block-all))
    (setq-local org-blocks-hidden (not org-blocks-hidden)))
  (add-hook 'org-mode-hook 'org-toggle-blocks)
  (define-key org-mode-map (kbd "C-c t") 'org-toggle-blocks)
  (global-set-key "\C-z'" 'poporg-dwim)
  (global-set-key (kbd "C-z <f5>") 'org-clock-goto)

switch to org-agenda file

My custom helm extension

(defvar avk-switch-to-org-agenda-file
  (helm-build-sync-source "Switch to org agenda file"
    :candidates 'org-agenda-files
    :action '(("Navidate to" . (lambda (file-name)
                                 (find-file file-name)
                                 ))

              )
    :persistent-help "Switch to org agenda file"))

(defun avk-switch-org-agenda-file ()
  (interactive)
  (helm :sources '(avk-switch-to-org-agenda-file))
  )

(define-key global-map (kbd "C-x O") 'avk-switch-org-agenda-file)

syntax highlight in code blocks

https://www.reddit.com/r/orgmode/comments/64tiq9/syntax_highlighting_in_code_blocks/

 (setq org-src-fontify-natively t
	 org-src-tab-acts-natively t
	 org-edit-src-content-indentation 0)

ox-rst

(use-package ox-rst)

ox-jira

(use-package ox-jira)

org-redmine

(use-package org-redmine
  :bind (
	      ("C-z r g" . org-redmine-get-issue)
	      )
  )

FIXME:

  (require 'org-redmine)
  (defun org-redmine-curl-args (uri)
    (let ((args '("-X" "GET" "-s" "-f" "--ciphers" "RC4-SHA:RC4-MD5")))
      (append
	args
	(cond (org-redmine-auth-api-key
	       `("-G" "-d"
		 ,(format "key=%s" org-redmine-auth-api-key)))
	      (org-redmine-auth-username
	       `("-u"
		 ,(format "%s:%s"
			  org-redmine-auth-username (or org-redmine-auth-password ""))))
	      (org-redmine-auth-netrc-use '("--netrc"))
	      (t ""))
	`(,uri))))
  (setq org-redmine-uri "https://<Your Redmine URL>")
  (setq org-redmine-auth-api-key "<Please set your Redmine API key here>")

org-bullets

Nice bullets for org-mode but somehow it makes editor a little slower, so I don’t always enable it.

(use-package org-bullets)

org-jira

(use-package org-jira)

org-habit

https://orgmode.org/manual/Tracking-your-habits.html https://orgmode.org/worg/org-tutorials/tracking-habits.html

(require 'org-habit)

ob-tmux

(use-package ob-tmux
  :init
  (setq org-babel-default-header-args:tmux
	     '((:results . "silent")		;
	       (:session . "default")	; The default tmux session to send code to
	       (:socket  . nil)              ; The default tmux socket to communicate with
	       ;; You can use "xterm" and "gnome-terminal".
	       ;; On mac, you can use "iterm" as well.
	       ))
  :config
  ;; The tmux sessions are prefixed with the following string.
  ;; You can customize this if you like.
  (setq org-babel-tmux-session-prefix "ob-")
  )

defadvice for time

from: https://kisaragi-hiu.com/blog/2019-10-09-format-time-string-today.html

(defun kisaragi/english-dow (&optional time zone abbreviated)
  "Return ABBREVIATED name of the day of week at TIME and ZONE.

If TIME or ZONE is nil, use `current-time' or `current-time-zone'."
  (unless time (setq time (current-time)))
  (unless zone (setq zone (current-time-zone)))
  (calendar-day-name
   (pcase-let ((`(,_ ,_ ,_ ,d ,m ,y . ,_)
                (decode-time time zone)))
     (list m d y))
   abbreviated))

(defun kisaragi/advice-format-time-string (func format &optional time zone)
  "Pass FORMAT, TIME, and ZONE to FUNC.

Replace \"%A\" in FORMAT with English day of week of today,
\"%a\" with the abbreviated version."
  (let* ((format (replace-regexp-in-string "%a" (kisaragi/english-dow time zone t)
                                           format))
         (format (replace-regexp-in-string "%A" (kisaragi/english-dow time zone nil)
                                           format)))
    (funcall func format time zone)))

(advice-add 'format-time-string :around #'kisaragi/advice-format-time-string)

org-msg

https://github.com/jeremy-compostella/org-msg

 (use-package org-msg)
 (setq org-msg-options "html-postamble:nil H:5 num:nil ^:{} toc:nil author:nil email:nil \\n:t"
	 org-msg-startup "hidestars indent inlineimages"
	 org-msg-greeting-fmt "\nHi%s,\n\n"
	 org-msg-greeting-name-limit 3
	 org-msg-default-alternatives '((new		. (text html))
					(reply-to-html	. (text html))
					(reply-to-text	. (text)))
	 org-msg-convert-citation t)
 (setq mail-user-agent 'notmuch-user-agent)

 (org-msg-mode)

folding?

(setq-local outline-regexp "^[A-Z]")
(setq-local outline-heading-end-regexp ".$")
(setq-local outline-minor-mode-prefix "C-~")
(outline-minor-mode)
(local-set-key outline-minor-mode-prefix outline-mode-prefix-map)

make exported org mode checkboxes clickable

Publish clickable org mode checklists

(defalias 'my-transform-and-publish-org-checklist
   (kmacro "C-s < / h e a d C-a <return> <up> <tab> j q u e r y <tab> <return> C-S-<backspace> C-s < / b o d y C-a <return> <up> <tab> m y - p r <backspace> <backspace> o r g - c h e c k b o x e s - c l i c k <tab> C-<left> C-<left> C-<left> C-SPC C-<left> C-w C-e <tab> <return> C-a <tab> C-x C-s M-w b M-x m y - p u b l i s h - f i l e <return>"))
(defun my-publish-org-checklist ()
  "Publish org-mode checklist to standard site"
  (interactive)
  (let ((temp-file-name (shell-command-to-string "date  +ok-%Y-%m-%d-%s.html | head -c -1")))
    (message temp-file-name)
    (call-interactively 'htmlize-buffer)
    (write-file temp-file-name)
    (call-interactively 'my-transform-and-publish-org-checklist)
    )
  )

org-ql

(use-package quelpa-use-package)
(use-package org-ql
  :bind (("C-c o" . org-ql-view))
  :quelpa (org-ql :fetcher github :repo "alphapapa/org-ql"
            :files (:defaults (:exclude "helm-org-ql.el"))))

learning agenda

(defalias 'my-org-agenda-learn
   (kmacro "C-c a 1 / l e a r n <return>"))

org-tree-slide show starts here

Thanks to: Org-mode - Start slide from current subtree

(defun my-org-tree-slide-show-starts-here ()
  (interactive)
  (setq org-tree-slide-cursor-init nil)
)

lsp-mode

(use-package lsp-mode
  :ensure t
  :custom
  (lsp-diagnostics-provider :none))

Language: go

(require 'go-template-mode)

ace, avy, councel

Jumping between frames, windows, lines, etc.

(use-package ace-window
  :bind (
         ("\M-[" . ace-window)
         )
  )
(global-set-key "\M-[" 'ace-window)
(global-set-key "\M-]" 'avy-goto-char-timer)

vertico

https://github.com/minad/vertico

;; Enable vertico
(use-package vertico
  :init
  ;; (vertico-mode)

  ;; Different scroll margin
  ;; (setq vertico-scroll-margin 0)

  ;; Show more candidates
  ;; (setq vertico-count 20)

  ;; Grow and shrink the Vertico minibuffer
  ;; (setq vertico-resize t)

  ;; Optionally enable cycling for `vertico-next' and `vertico-previous'.
  ;; (setq vertico-cycle t)
:bind (
       ;; ("C-c C-r" . ivy-resume)
       ([C-f12] . vertico-mode)
       ([s-f12] . vertico-mode)
       )

  )

;; Persist history over Emacs restarts. Vertico sorts by history position.
(use-package savehist
  :init
  (savehist-mode))

;; A few more useful configurations...
(use-package emacs
  :init
  ;; Add prompt indicator to `completing-read-multiple'.
  ;; We display [CRM<separator>], e.g., [CRM,] if the separator is a comma.
  (defun crm-indicator (args)
    (cons (format "[CRM%s] %s"
                  (replace-regexp-in-string
                   "\\`\\[.*?]\\*\\|\\[.*?]\\*\\'" ""
                   crm-separator)
                  (car args))
          (cdr args)))
  (advice-add #'completing-read-multiple :filter-args #'crm-indicator)

  ;; Do not allow the cursor in the minibuffer prompt
  (setq minibuffer-prompt-properties
        '(read-only t cursor-intangible t face minibuffer-prompt))
  (add-hook 'minibuffer-setup-hook #'cursor-intangible-mode)

  ;; Emacs 28: Hide commands in M-x which do not work in the current mode.
  ;; Vertico commands are hidden in normal buffers.
  ;; (setq read-extended-command-predicate
  ;;       #'command-completion-default-include-p)

  ;; Enable recursive minibuffers
  (setq enable-recursive-minibuffers t))

;; https://github.com/minad/vertico
;; Similar to org-refile, the commands org-agenda-filter and org-tags-view do not make use of completion boundaries.
(defun org-enforce-basic-completion (&rest args)
  (minibuffer-with-setup-hook
      (:append
       (lambda ()
         (let ((map (make-sparse-keymap)))
           (define-key map [tab] #'minibuffer-complete)
           (use-local-map (make-composed-keymap (list map) (current-local-map))))
         (setq-local completion-styles (cons 'basic completion-styles)
                     vertico-preselect 'prompt)))
    (apply args)))
(advice-add #'org-make-tags-matcher :around #'org-enforce-basic-completion)
(advice-add #'org-agenda-filter :around #'org-enforce-basic-completion)

icomplete

(global-set-key [s-f11] 'icomplete-mode)
(icomplete-mode nil)

apache mode

(use-package apache-mode)

annotate-mode

(use-package annotate
  :defer t
  :bind (
	     ("\C-cma" . annotate-mode)
	     ))

crontab-mode

(use-package crontab-mode)

deadgrep

Another method to search

(use-package deadgrep
  :bind (
	     (
	      ("C-c d" . deadgrep)
	      )
	     ))

dired

   ;; (dired-async-mode 1)
   (setq dired-omit-files "^\\...+$")
   ;;(defun avk-dired-mode-hook ()
   ;; (local-set-key [(tab)] 'other-window))

   ;; (add-hook 'dired-mode-hook 'avk-dired-mode-hook)
   (defun open-file-externally(arg)
     (async-shell-command (format "xdg-open \"%s\"" arg))
     )

   (defun open-files-externally()
     "Open marked files (or current one) to edit via ansible-vault."
     (interactive)
     (mapc 'open-file-externally (dired-get-marked-files t))
     )

   (global-set-key (kbd "C-c e") 'open-files-externally)

   (add-to-list 'auto-mode-alist '("all.open" . yaml-mode))

   (define-key dired-mode-map ";" 'dired-subtree-toggle)

   (defun dired-get-size ()
     (interactive)
     (let ((files (dired-get-marked-files)))
	(with-temp-buffer
	  (apply 'call-process "/usr/bin/du" nil t nil "-sch" files)
	  (message "Size of all marked files: %s"
		   (progn
		     (re-search-backward "\\(^[0-9.,]+[A-Za-z]+\\).*total$")
		     (match-string 1))))))

   (define-key dired-mode-map (kbd "?") 'dired-get-size)
   (define-key global-map  "\C-xj"         'dired-jump)
   (define-key global-map  "\C-cfd"         'find-dired)

   (autoload 'dired-async-mode "dired-async.el" nil t)
   ;;(add-hook 'dired-mode-hook
   ;;     (lambda ()
   ;;       (dired-hide-details-mode)
   ;;       ))

Ansible/DevOps related - edit vault files with emacsclient.

   (defun open-vault-file(arg)
     "Decrypt vault file specified in ARG by calling ansible-vault and .vaultfile password
      from any upper directory"
     (let ((vaultfile ".vaultfile"))
	(let ((vault-file-dir (locate-dominating-file default-directory vaultfile)))
	  (if vault-file-dir
	      (call-process "ansible-vault" nil 0 nil
			    "edit" arg
			    "--vault-password-file"
			    (concat vault-file-dir ".vaultfile")
			    )
	    (message (format "%s not found in current or upper directories" vaultfile)))
	  ))
     )
   (defun open-vault-files()
     "Open marked files (or current one) to edit via ansible-vault."
     (interactive)
     (require 'server)
     (unless (server-running-p)
	(server-start))
     (setenv "EDITOR" "emacsclient")
     (message "open vault file")
     (mapc 'open-vault-file (dired-get-marked-files t))
     )

   (global-set-key (kbd "C-z v") 'open-vault-files)

coloring

(use-package diredfl
  :ensure t
  :config
  (diredfl-global-mode 1))

dired-sidebar

Interesting alternative to treemacs

  (use-package all-the-icons-dired)

  (use-package dired-sidebar
    :bind (("C-x C-n" . dired-sidebar-toggle-sidebar))
    :ensure t
    :commands (dired-sidebar-toggle-sidebar)
    :init
    (add-hook 'dired-sidebar-mode-hook
		 (lambda ()
		   (unless (file-remote-p default-directory)
		     (auto-revert-mode))))
    :config
    (push 'toggle-window-split dired-sidebar-toggle-hidden-commands)
    (push 'rotate-windows dired-sidebar-toggle-hidden-commands)

    ;; (setq dired-sidebar-subtree-line-prefix "__")
    ;; (setq dired-sidebar-theme 'vscode)
    (setq dired-sidebar-use-term-integration t)
    ;;(setq dired-sidebar-use-custom-font t)
    )

git info

(use-package dired-git-info
  :ensure t
  :bind (:map dired-mode-map
		   (")" . dired-git-info-mode)))

elfeed

(defalias 'elfeed-mark-read
  (kmacro "<return> q"))

(use-package elfeed
  :bind (:map elfeed-search-mode-map
		  ("r" . elfeed-mark-read)
		  ("`" . elfeed-mark-read)
		  )
  )

docker support

(use-package docker)
(use-package dockerfile-mode)
(add-to-list 'auto-mode-alist '("Dockerfile\\.*" . dockerfile-mode))
(add-to-list 'auto-mode-alist '("\.*\.docker" . dockerfile-mode))

nginx

(use-package nginx-mode)

poetry

(use-package poetry
  :ensure t)

expand-region

Expand region.

   (use-package expand-region
     :bind (
	     ("C-;" . er/expand-region)
	     ("C-'" . er/mark-inside-quotes)
	     ))

   (defun tree-sitter-mark-bigger-node ()
     (interactive)
     (let* ((p (point))
	     (m (or (mark) p))
	     (beg (min p m))
	     (end (max p m))
	     (root (ts-root-node tree-sitter-tree))
	     (node (ts-get-descendant-for-position-range root beg end))
	     (node-beg (ts-node-start-position node))
	     (node-end (ts-node-end-position node)))
	;; Node fits the region exactly. Try its parent node instead.
	(when (and (= beg node-beg) (= end node-end))
	  (when-let ((node (ts-get-parent node)))
	    (setq node-beg (ts-node-start-position node)
		  node-end (ts-node-end-position node))))
	(set-mark node-end)
	(goto-char node-beg)))

   ;; FIXME
   ;; (setq er/try-expand-list (append er/try-expand-list
   ;; 				 '(tree-sitter-mark-bigger-node)))

git & magit & github

Special keybinding is not set as its rarely used operation, and so use M-x git-l

(use-package magit
  :bind (("C-x g" . magit-status)))

(use-package git-link
  :bind (
         ("C-c g" . git-link)
         )
  )
(use-package magit-todos)
(use-package forge
  :after magit)
(use-package github-review)

(defalias 'my-insert-git-link
  (kmacro "C-c C-o M-x g i t - l i n k <return> s-w C-<escape> <end> SPC [ [ C-y ] [ . . C-x 8 <return> 2 1 9 2 <return> ] ]"))
(use-package ledger-mode
  :init
  (magit-todos-mode)
)

magit-todos

multiple-cursors

(use-package multiple-cursors
  ;; :bind (
  ;; ("C-z c e" . mc/edit-lines)
  ;; ("C-z c *" . mc/mark-all-like-this)
  ;; ("s-." . mc/mark-next-like-this)
  ;; ("s-," . mc/mark-previous-like-this)
  ;; )
  )
(global-set-key (kbd "C-z c e") 'mc/edit-lines)
(global-set-key (kbd "C-z c *") 'mc/mark-all-like-this)
(global-set-key (kbd "C-s-.") 'mc/mark-next-like-this)
(global-set-key (kbd "C-s-,") 'mc/mark-previous-like-this)

Phi-search

(use-package phi-search
  :bind (
	     ("C-c C-s" . phi-search)
	     ("C-c C-r" . phi-search-backward)
	     ))

hl-todo

Highlight TODO, FIXME, etc faces

(use-package hl-todo
  :config
  (global-hl-todo-mode)
  )

javascript

   (defun my-js-console-log (arg)
     "Insert js console.log(). Prefix argument will ask for string or variable name"
     (interactive "P")
     (message "raw prefix arg is %S" arg)
     (insert "console.log(\"")
     (when (equal '(4) arg)
	(insert (read-from-minibuffer "Prefix text: ") " ")
	)
     (insert (shell-command-to-string "date  +\"ok-%Y-%m-%d-%s\" | tr -d '\\n'"))
     (if (equal 1 arg)
	  (insert "\" + );")
	(insert "\");"))
     )

   (eval-after-load 'typescript-ts-mode
     '(progn
	 (define-key typescript-ts-mode-map (kbd "C-z q") 'my-js-console-log)
	 ))

   (eval-after-load 'typescript-mode
     '(progn
	 (define-key typescript-mode-map (kbd "C-z q") 'my-js-console-log)
	 ))

   (use-package js2-mode)
   ;; (use-package js3-mode)
   ;; (use-package js2-refactor)
   (add-to-list 'auto-mode-alist '("\\.js$" . js2-mode))
   (setq js-indent-level 2)

json-mode

(use-package json-mode)

imenu

(use-package imenu-list)

ledger

(use-package ledger-mode
  :init
  (magit-todos-mode)
  )

logview

https://github.com/doublep/logview

(use-package logview)

notmuch

Email setup

   (use-package notmuch
     :init
     (progn
	;; (require 'org-notmuch)
	(require 'org-notmuch)
	(require 'notmuch-address)
	(setq notmuch-address-command "~/bin/notmuch_addresses.py")
	)
     :bind (
	     ("C-z z" . notmuch)
	     ("C-c C-o" . browse-url-at-point)
	     )
     :config

     (defun notmuch-show-tag-spam ()
	"mark message as spam"
	(interactive)
	(notmuch-search-tag '("+spam" "-inbox" "-unread"))
	(next-line)
	)
     (define-key notmuch-search-mode-map "S" 'notmuch-show-tag-spam)
     (defun notmuch-show-tag-deleted ()
	"mark message as deleted"
	(interactive)
	(notmuch-search-tag '("+deleted" "-inbox")))

     (defun notmuch-show-tag-read ()
	"mark message as read"
	(interactive)
	(notmuch-search-tag '("-unread"))
	(next-line)
	)

     (define-key notmuch-search-mode-map "d" 'notmuch-show-tag-deleted)
     (define-key notmuch-search-mode-map "~" 'notmuch-show-tag-read)
     (define-key notmuch-search-mode-map "`" 'notmuch-show-tag-read)

     )

   (defun notmuch-show-tag-spam ()
     "mark message as spam"
     (interactive)
     (notmuch-search-tag '("+spam" "-inbox" "-unread"))
     (next-line)
     )
   ;;(define-key notmuch-search-mode-map "S" 'notmuch-show-tag-spam)

   (defun notmuch-show-tag-deleted ()
     "mark message as deleted"
     (interactive)
     (notmuch-search-tag '("+deleted" "-inbox")))

   (defun notmuch-show-tag-read ()
     "mark message as read"
     (interactive)
     (notmuch-search-tag '("-unread"))
     (next-line)

     ;; Sign messages by default.
     (add-hook 'message-setup-hook 'mml-secure-sign-pgpmime)

     (custom-set-variables
      '(notmuch-search-oldest-first nil)
      '(notmuch-crypto-process-mime t)
      '(notmuch-message-headers (quote ("Subject" "To" "Cc" "Date" "X-Mailer" "User-Agent")))
      '(notmuch-fcc-dirs "ua2web/INBOX.sent"))
     (add-hook 'notmuch-show-hook 'hide-trailing-whitespace)

     (defun expand-only-unread-hook ()
	"eexpand only recent unreads"
	(interactive)
	(let ((unread nil)
	      (open (notmuch-show-get-message-ids-for-open-messages)))
	  (notmuch-show-mapc (lambda ()
			       (when (member "unread" (notmuch-show-get-tags))
				 (setq unread t))))
	  (when unread
	    (let ((notmuch-show-hook (remove 'expand-only-unread-hook notmuch-show-hook)))
	      (notmuch-show-filter-thread "tag:unread")))))

     (add-hook 'notmuch-show-hook 'expand-only-unread-hook)

     )

I have several mail accounts in different companies, and I need to originate my replys according to company. It appears notmuch don’t have this functionality by default, so I’ve monkey patched it here:

   (defadvice notmuch-mua-reply (around notmuch-fix-sender)
     (let ((sender (notmuch-mua-prompt-for-sender)))
	 ad-do-it))
   (ad-activate 'notmuch-mua-reply)

smtpmail

(use-package smtpmail-multi)

pdf-tools

(use-package pdf-tools
  :config
  (pdf-tools-install)
  )

pass

(use-package pass)

php-mode

(use-package php-mode)

plantuml-mode

(use-package plantuml-mode)
(add-to-list 'auto-mode-alist '("\\.plantuml\\'" . plantuml-mode))

;; Sample jar configuration
(setq plantuml-jar-path "~/.emacs.d/plantuml.jar")
(setq plantuml-default-exec-mode 'jar)
(add-to-list
 'org-src-lang-modes '("plantuml" . plantuml))

pylookup

https://github.com/tsgates/pylookup - Python sphinx documenation engine indexing & access form Emacs.

;; load pylookup when compile time
(eval-when-compile (require 'pylookup))
(setq pylookup-program "~/.emacs.d/pylookup.py")
(setq pylookup-db-file "~/var/pylookup/pylookup.db")
(global-set-key [(control shift menu)] 'pylookup-lookup)

python (new)

 (defun python-create-empty-init-py()
   (interactive)
   (shell-command "touch __init__.py")
   )
 (global-set-key (kbd "C-z p i") 'python-create-empty-init-py)
 ;; (add-hook 'python-mode-hook
 ;; 	  (setq indent-tabs-mode nil)
 ;; 	  (setq tab-width 4)
 ;; 	  (flycheck-mode)
 ;; 	  )

 ;; (setq pym
 ;;       acs-python-command "/usr/bin/python3")
 (defun pycodestyle-current-buffer()
   (interactive)
   (compile (concat "pycodestyle " (buffer-file-name)) nil)
   )
 (global-set-key (kbd "C-c p 8") 'pycodestyle-current-buffer)

 (use-package pylint
   :bind (("C-c p l" . pylint))
   )

 (defun my-flake8-current-dir()
   (interactive)
   (compile "flake8" nil)
   )

 (global-set-key (kbd "C-z 8") 'my-flake8-current-dir)


 (defun my-isort-current-dir()
   (interactive)
   (compile (concat "isort " (buffer-file-name)) nil)
   )

 (global-set-key (kbd "C-c p i") 'my-isort-current-dir)



 ;; (defun flake8-current-buffer()
 ;;   (interactive)
 ;;   (compile (concat "flake8 " (buffer-file-name)) nil)
 ;;   (switch-to-buffer "*compilation*")
 ;;   (rename-buffer "*flake8*")
 ;;   )

 (defun flake8-current-buffer()
   (interactive)
   (compile (concat "flake8 " (buffer-file-name)) nil)
   )

;; (add-hook 'compilation-finish-functions 'switch-to-buffer-other-window 'compilation)

 (global-set-key (kbd "C-c p f") 'flake8-current-buffer)


 (use-package highlight-indentation
   :bind (("C-z <f12>" . highlight-indentation-mode))
   :defer t)
 ;;(global-set-key (kbd "C-z 9") 'compile)

 (add-hook 'python-mode-hook
           '(lambda ()
              (global-set-key [(control shift menu)] 'pylookup-lookup)
              ;;	       (highlight-indentation-mode t)
              (display-line-numbers-mode nil)
              (define-key python-mode-map "\C-m" 'newline-and-indent)
              (if (buffer-file-name)
                  (if (file-remote-p (buffer-file-name))
                      (flymake-mode)
                    (flycheck-mode t))
                )
              (lsp-mode)
              (apheleia-mode +1)
              (setq-local flycheck-checker 'python-pycheckers)
              )
           )

 (define-key global-map (kbd "C-z p l") 'pylookup-lookup)
 (define-key global-map (kbd "C-z C-o") 'pylookup-lookup)



 (add-hook 'python-ts-mode-hook
           '(lambda ()
              (define-key python-ts-mode-map "\C-m" 'newline-and-indent)
              (if (buffer-file-name)
                  (if (file-remote-p (buffer-file-name))
                      (flymake-mode)
                    (flycheck-mode t))
                )
              (apheleia-mode +1)
              (setq-local flycheck-checker 'python-pycheckers)
              )
           )

lsp-jedi

In most of cases I use lsp-bridge now, but there are keybindings to manually switch to lsp-jedi - this mode has some interesting features too.

(use-package lsp-jedi
  :ensure t
  :config
  (with-eval-after-load "lsp-mode"
    (add-to-list 'lsp-disabled-clients 'pyls)
    (add-to-list 'lsp-enabled-clients 'jedi)))


(defun my-enable-lsp-jedi ()
  (interactive)
  (add-hook 'python-ts-mode-hook #'lsp-mode)
  )

(defun my-disable-lsp-jedi ()
  (interactive)
  (remove-hook 'python-ts-mode-hook #'lsp-mode)
  )

isort

(use-package py-isort)

pyimport

(use-package pyinspect)
(use-package pyimpsort)
(use-package pyimport)

shrink-whitespace

(use-package shrink-whitespace
  :bind (
	     ("M-\\" . shrink-whitespace)
	     ))

org-roam

 (use-package org-roam
   :ensure t
   :custom(org-roam-directory "~/org-roam")
   :bind (("C-c n l" . org-roam-buffer-toggle)
	   ("C-c n f" . org-roam-node-find)
	   ("C-c n t" . org-roam-tag-add)
	   ("C-c n r" . org-roam-tag-remove)
	   ("C-c n i" . org-roam-node-insert))
   :config
   (org-roam-setup)
   )

 (setq org-roam-node-display-template
	(concat "${title:*} "
		(propertize "${tags:10}" 'face 'org-tag)))

 ;; https://www.reddit.com/r/emacs/comments/123gu1l/how_to_have_history_suggestion_in_vertico_for_mx/
 (use-package consult
   :bind (
	   :map minibuffer-local-map
		("M-s" . consult-history)                 ;; orig. next-matching-history-element
		("M-r" . consult-history)))

 (use-package consult-org-roam
   :ensure t
   :after org-roam
   :init
   (require 'consult-org-roam)
   ;; Activate the minor mode
   (consult-org-roam-mode 1)
   :custom
   ;; Use `ripgrep' for searching with `consult-org-roam-search'
   (consult-org-roam-grep-func #'consult-ripgrep)
   ;; Configure a custom narrow key for `consult-buffer'
   (consult-org-roam-buffer-narrow-key ?r)
   ;; Display org-roam buffers right after non-org-roam buffers
   ;; in consult-buffer (and not down at the bottom)
   (consult-org-roam-buffer-after-buffers t)
   :config
   ;; Eventually suppress previewing for certain functions
   (consult-customize
    consult-org-roam-forward-links
    :preview-key (kbd "M-."))
   :bind
   ;; Define some convenient keybindings as an addition
   ("C-c n e" . consult-org-roam-file-find)
   ("C-c n b" . consult-org-roam-backlinks)
   ("C-c n l" . consult-org-roam-forward-links)
   ("C-c n r" . consult-org-roam-search))

tramp

   ;; from http://stackoverflow.com/questions/840279/passwords-in-emacs-tramp-mode-editing
   (require 'tramp)
   (require 'password-cache)
   (setq password-cache-expiry nil)

   ;; Open files in Docker containers like so: /docker:drunk_bardeen:/etc/passwd
   ;; (push
   ;;  (cons
   ;;   "docker"
   ;;   '((tramp-login-program "docker")
   ;;     (tramp-login-args (("exec" "-it") ("%h") ("/bin/sh")))
   ;;     (tramp-remote-shell "/bin/sh")
   ;;     (tramp-remote-shell-args ("-i") ("-c"))))
   ;;  tramp-methods)

   (defadvice tramp-completion-handle-file-name-all-completions
	(around dotemacs-completion-docker activate)
     "(tramp-completion-handle-file-name-all-completions \"\" \"/docker:\" returns
	a list of active Docker container names, followed by colons."
     (if (equal (ad-get-arg 1) "/docker:")
	  (let* ((dockernames-raw (shell-command-to-string "docker ps | awk '$NF != \"NAMES\" { print $NF \":\" }'"))
		 (dockernames (cl-remove-if-not
			       #'(lambda (dockerline) (string-match ":$" dockerline))
			       (split-string dockernames-raw "\n"))))
	    (setq ad-return-value dockernames)
	    (message dockernames)
	    )
	ad-do-it))

   ;; Problem with su: often many system accounts are hidden under /sbin/nologin due to reasons explained here:
   ;; https://unix.stackexchange.com/questions/155139/does-usr-sbin-nologin-as-a-login-shell-serve-a-security-purpose
   ;; ... as result 'su' won't work, but with lisp it is easy to define 'sush' which will do -s /bin/sh
   (push
    (cons
     "sush"
     '((tramp-login-program "su")
	(tramp-login-args (("-") ("%u") ("-s" "/bin/sh")))
	(tramp-remote-shell "/bin/sh")
	(tramp-remote-shell-login
	 ("-l"))
	(tramp-remote-shell-args
	 ("-c"))
	(tramp-connection-timeout 10)))
    tramp-methods)
   ;;

   ;; from https://emacs.stackexchange.com/questions/17543/tramp-mode-is-much-slower-than-using-terminal-to-ssh
   (setq remote-file-name-inhibit-cache nil)
   (setq vc-ignore-dir-regexp
	  (format "%s\\|%s"
		  vc-ignore-dir-regexp
		  tramp-file-name-regexp))
   (setq tramp-verbose 1)


   (push
    (cons
     "ocrsh"
     '((tramp-login-program "oc")
	(tramp-login-args (("rsh") ("%h") ("/bin/sh")))
	(tramp-remote-shell "/bin/sh")
	(tramp-remote-shell-args ("-i"))))
    tramp-methods)

   (push
    (cons
     "kube"
     '((tramp-login-program "kubectl")
	(tramp-login-args (("exec") ("%h") ("-it") ("/bin/sh")))
	(tramp-remote-shell "/bin/sh")
	(tramp-remote-shell-args ("-i"))))
    tramp-methods)

   (defun tramp-refresh ()
     (interactive)
     ;; (recentf-cleanup)
     (tramp-cleanup-all-buffers)
     (tramp-cleanup-all-connections))

   ;; https://www.gnu.org/software/emacs/manual/html_node/tramp/Auto_002dsave-and-Backup.html
   (add-to-list 'backup-directory-alist
		 (cons tramp-file-name-regexp nil))


   (add-to-list 'tramp-connection-properties
		 (list (regexp-quote "/sudo:")
		       "session-timeout" nil)
		 )

   (add-to-list 'tramp-connection-properties
		 (list (regexp-quote "/ssh:")
		       "session-timeout" nil)
		 )


   (use-package friendly-tramp-path
     :after tramp)

yasnippet

Snippets for various languages

(use-package yasnippet)
(yas-global-mode 1)

ztree

   (use-package ztree)
   (defun ztree-do-dired ()
     (interactive)
     "Jump to dired in specified place of ZTree-dir"
     (let* ((line (line-number-at-pos))
	     (node (ztree-find-node-in-line line)))
	(when node
	  (dired node))
	)
     )
   (define-key ztree-mode-map (kbd "D") 'ztree-do-dired)
					    ; (global-set-key [f5] 'ztree-dir)
   (global-set-key (kbd "C-x <f5>") 'ztree-dir)
   (global-set-key (kbd "M-<f3>") 'ztree-dir)

   (fset 'ztree-side
	  [?\C-x ?z return ?\C-x ?3 ?\C-x ?\C-- ?\C-x ?w ?w ?\s-w ?\C-x right ?\s-w])
   (global-set-key (kbd "<C-f3>") 'ztree-side)

which-key - Discover key bindings

(use-package which-key
  :config
  (setq which-key-mode t)
  (setq which-key-idle-delay 0.7)
  )

recentf

Since yesterday emacs update [2019-03-07 Thu] recentf started aggressive cleanup of all tramp-related buffers, and no controls affect it (auto cleanup was always disabled).

Quick workaround:

(use-package recentf
  :init
  (setq
    recentf-save-file "~/.cache/emacs-recentf"
    recentf-max-saved-items 10000
    recentf-max-menu-items 5000
    )
  (recentf-mode 1)
  (run-at-time nil (* 5 60) 'recentf-save-list)
  )
(load "~/.cache/emacs-recentf" t)

realgud

Real good debugger.

(use-package realgud)

vue

;; (use-package lsp-mode
;;   :commands lsp)

;; ;; for completions
;; ;; (use-package company-lsp
;; ;;   :after lsp-mode
;; ;;   :config (push 'company-lsp company-backends))

;; (use-package vue-mode
;;   :mode "\\.vue\\'"
;;   :config
;;   (add-hook 'vue-mode-hook #'lsp))

(add-to-list 'auto-mode-alist '("\\.vue" . web-mode))
;; (add-to-list 'auto-mode-alist '("\\.vue" . tide-mode))
;; (apheleia-global-mode +1)

yaml-mode

  (use-package yaml-mode)
  (use-package indent-tools)
  (add-hook 'yaml-mode-hook
	      '(lambda ()
		 (highlight-indentation-mode t)
		 (display-line-numbers-mode t)
		 (highlight-changes-mode nil)
		 (if (buffer-file-name)
		     (if (file-remote-p (buffer-file-name))
			 (flymake-mode)
		       (flycheck-mode t))
		   )
		 )
	      )

  ;; https://stackoverflow.com/questions/12648388/emacs-yaml-editing

  (defun yaml-next-field ()
    "Jump to next yaml field"
    (interactive)
    (search-forward-regexp ": *"))

  (defun yaml-prev-field ()
    "Jump to next yaml field"
    (interactive)
    (search-backward-regexp ": *"))

  (add-hook 'yaml-mode-hook
	      (lambda ()
		(display-line-numbers-mode t)
		(define-key yaml-mode-map "\C-m" 'newline-and-indent)
		(define-key yaml-mode-map "\M-\r" 'insert-ts)
		(define-key yaml-mode-map (kbd "C-<tab>") 'yaml-next-field)
		(define-key yaml-mode-map (kbd "C-S-<tab>") 'yaml-prev-field)
		)
	      )

  (require 'indent-tools)
  (global-set-key (kbd "C-c .") 'indent-tools-hydra/body)

shells

                                        ; various shells
(require 'python)
(add-hook 'shell-output-filter-functions
          '(lambda () ""
             (when (shell-interactive-process)
               (python-pdbtrack-set-tracked-buffer
                (buffer-substring (shell-beginning-of-output) shell-last-output-end)))))

(global-unset-key (kbd "s-s"))
(defun switch-to-shell(n) ()
       (interactive)
       (if (get-buffer (concat "*shell*<" n ">"))
           (switch-to-buffer (concat "*shell*<" n ">"))
         (shell (concat "*shell*<" n ">")))
       )

(global-set-key (kbd "C-z C-1") (lambda () (interactive) (switch-to-shell "1")))
(global-set-key (kbd "C-z C-2") (lambda () (interactive) (switch-to-shell "2")))
(global-set-key (kbd "C-z C-3") (lambda () (interactive) (switch-to-shell "3")))
(global-set-key (kbd "C-z C-4") (lambda () (interactive) (switch-to-shell "4")))
(global-set-key (kbd "C-z C-5") (lambda () (interactive) (switch-to-shell "5")))
(global-set-key (kbd "C-z C-6") (lambda () (interactive) (switch-to-shell "6")))
(global-set-key (kbd "C-z C-7") (lambda () (interactive) (switch-to-shell "7")))
(global-set-key (kbd "C-z C-8") (lambda () (interactive) (switch-to-shell "8")))
(global-set-key (kbd "C-z C-9") (lambda () (interactive) (switch-to-shell "9")))
(global-set-key (kbd "C-z C-0") 'shell)
(global-set-key (kbd "C-z C-e") 'eshell)

(global-set-key (kbd "C-z x 1") (lambda () (interactive) (switch-to-shell "1")))
(global-set-key (kbd "C-z x 2") (lambda () (interactive) (switch-to-shell "2")))
(global-set-key (kbd "C-z x 3") (lambda () (interactive) (switch-to-shell "3")))
(global-set-key (kbd "C-z x 4") (lambda () (interactive) (switch-to-shell "4")))
(global-set-key (kbd "C-z x 5") (lambda () (interactive) (switch-to-shell "5")))
(global-set-key (kbd "C-z x 6") (lambda () (interactive) (switch-to-shell "6")))
(global-set-key (kbd "C-z x 7") (lambda () (interactive) (switch-to-shell "7")))
(global-set-key (kbd "C-z x 8") (lambda () (interactive) (switch-to-shell "8")))
(global-set-key (kbd "C-z x 9") (lambda () (interactive) (switch-to-shell "9")))
(global-set-key (kbd "C-z x 0") 'shell)


                                        ; ansi-term
(defun switch-to-ansi-term(n) ()
       (interactive)
       (setq ansi-term-color-vector
             [term term-color-black term-color-red term-color-green term-color-yellow
                   term-color-blue term-color-magenta term-color-cyan term-color-white])
       (if (get-buffer (concat "**ansi-term<" n ">**"))
           (switch-to-buffer (concat "**ansi-term<" n ">**"))
         (ansi-term "/bin/zsh" (concat "*ansi-term<" n ">*")))
       )

(global-set-key [(control meta menu)] 'pylookup-lookup)
(global-set-key (kbd "C-x a 1") (lambda () (interactive) (switch-to-ansi-term "1")))
(global-set-key (kbd "C-x a 2") (lambda () (interactive) (switch-to-ansi-term "2")))
(global-set-key (kbd "C-x a 3") (lambda () (interactive) (switch-to-ansi-term "3")))
(global-set-key (kbd "C-x a 4") (lambda () (interactive) (switch-to-ansi-term "4")))
(global-set-key (kbd "C-x a 5") (lambda () (interactive) (switch-to-ansi-term "5")))
(global-set-key (kbd "C-x a 6") (lambda () (interactive) (switch-to-ansi-term "6")))
(global-set-key (kbd "C-x a 7") (lambda () (interactive) (switch-to-ansi-term "7")))
(global-set-key (kbd "C-x a 8") (lambda () (interactive) (switch-to-ansi-term "8")))
(global-set-key (kbd "C-x a 9") (lambda () (interactive) (switch-to-ansi-term "9")))
(global-set-key (kbd "C-x a 0") 'ansi-term)

;; http://emacs.stackexchange.com/questions/5585/how-to-copy-command-output-in-ansi-term-mode
(require 'term)
(defun jnm/term-toggle-mode ()
  "Toggles term between line mode and char mode"
  (interactive)
  (if (term-in-line-mode)
      (term-char-mode)
    (term-line-mode)))

(define-key term-mode-map (kbd "C-c C-j") 'jnm/term-toggle-mode)
(define-key term-mode-map (kbd "C-c C-k") 'jnm/term-toggle-mode)

(define-key term-raw-map (kbd "C-c C-j") 'jnm/term-toggle-mode)
(define-key term-raw-map (kbd "C-c C-k") 'jnm/term-toggle-mode)

(global-set-key (kbd "s-s t") '(lambda ()
                                 (interactive)
                                 (call-process "i3-sensible-terminal" nil 0 nil)))

(fset 'myshells
      [?\M-x ?i ?b ?u ?f ?f ?e ?r return ?/ ?/ ?/ ?m ?s ?h ?e ?l ?l ?- ?m ?o ?d ?e return ?s ?f])

(global-set-key (kbd "s-s l") 'myshells)

(defun my-shell-mode-hook ()
  (hide-trailing-whitespace)
  (company-mode)
  )

(add-hook 'shell-mode-hook 'my-shell-mode-hook)
(add-hook 'term-mode-hook 'my-shell-mode-hook)

;; from http://stackoverflow.com/questions/13185729/npm-dont-display-prompt-correctly-under-emacs-eshell
;; to filter out npm special chars
(add-to-list
 'comint-preoutput-filter-functions
 (lambda (output)
   (replace-regexp-in-string "\033\[[0-9]+[AGK]" "" output)))

(defun ansible-highlight()
  "Hightlight ok, failed, changed lines"
  (interactive)
  (highlight-lines-matching-regexp "^ok:" 'hi-green-b)
  (highlight-phrase "failed:" 'flycheck-error)
  (highlight-phrase "FAILED\!" 'flycheck-error)
  (highlight-lines-matching-regexp "changed:" 'font-lock-warning-face)
  )

(defun sql-highlight()
  "SQL updates, inserts"
  (interactive)
  (highlight-lines-matching-regexp "INSERT\sINTO\s" 'hi-pink)
  (highlight-lines-matching-regexp "DELETE\sFROM\s" 'hi-red-b)
  (highlight-lines-matching-regexp "UPDATE\s" 'hi-yellow)
  )

shell comint input history

(add-hook 'shell-mode-hook 'my-shell-mode-hook2)
(defun my-shell-mode-hook2 ()
  (setq comint-input-ring-file-name "~/.histfile")
  (comint-read-input-ring t))

prog-mode

;;   Always display line numbers in all sub-modes
(add-hook 'prog-mode-hook 'display-line-numbers-mode)

Unsorted keybindings (FIXME!)

I need to cleanup it. Later!

;; (global-set-key [f7]  'man)
(global-set-key [(shift f1)] 'helm-man-woman)
;; (global-set-key [f2]  'save-buffer)
(global-set-key [f3]  'find-file)
;; (global-set-key [f6]  'next-multiframe-window)
;; (global-set-key [f7]  'query-replace) # Use M-% or C-M-% instead
(global-set-key [S-f7]  'search-forward-regexp)
(global-set-key [M-f7]  'query-replace-regexp)

(defun my-f8key()
  (interactive)
  (if (bound-and-true-p flymake-mode)
      (flymake-goto-next-error)
    (flycheck-list-errors)
    )
  )

(global-set-key [M-f8]  'my-f8key)
(global-set-key [f8]  'my-f8key)

(global-set-key [C-f6] 'bookmark-jump)
(global-set-key [(shift f8)] 'flymake-goto-previous-error)
(global-set-key [f11] 'display-line-numbers-mode)
;; f10 - std emacs key binding (menu-bar)
(global-set-key [C-f10] 'menu-bar-mode)
(global-set-key [f12] 'toggle-truncate-lines)
(global-set-key (kbd "C-x t") 'toggle-truncate-lines)
;; (global-set-key (kbd "C-x b") 'ivy-switch-buffer)

;; man/help
;; (global-set-key [(meta f1)] 'man)

                                        ; other function key combinations
(global-set-key [C-f9] 'compile)
(global-set-key (kbd "C-z 9") 'compile)
(global-set-key (kbd "C-z R") 'recompile)
(global-set-key (kbd "C-z c c") 'compile)
(global-set-key [C-f7] 'rgrep)
(global-set-key (kbd "C-z 7") 'rgrep)

;; alternative ways to open file
(global-set-key [M-f3] 'helm-find-files) ;; this is using IDO mode/std
(global-set-key [(shift f3)] 'find-file-at-point) ;; this is std. emacs open



;; window movement - <shift> <win> + <arrow key>
(global-set-key [(shift s left)] 'windmove-left)
(global-set-key [(shift s right)] 'windmove-right)
(global-set-key [(shift s up)] 'windmove-up)
(global-set-key [(shift s down)] 'windmove-down)
(global-set-key [(s w)] 'other-window)
(global-set-key "\C-z-" 'previous-window-any-frame)
(global-set-key "\C-z+" 'next-window-any-frame)

(global-set-key [(s q)] 'delete-other-windows)


(global-set-key [mouse-2] 'yank) ;; paste on middle mouse key

(global-set-key [(control \#)] 'comment-or-uncomment-region)
(global-set-key [(control shift x)] 'comment-or-uncomment-region)
(global-set-key [(control shift f7)] 'occur)
(global-set-key [XF86Reload] 'ido-switch-buffer)

                                        ;

(global-set-key [Scroll_Lock] 'speedbar)


;; quick manual override of mode switch
;; memoize: c -Control m -Mode
;;(define-key global-map  "\C-cmj"         'javascript-mode)
(define-key global-map  "\C-cmj"         'js2-mode)
(define-key global-map  "\C-cmp"         'python-mode)
(define-key global-map  "\C-cm1"         'flycheck-mode)
(define-key global-map  "\C-cm2"         'python-ts-mode)
(define-key global-map  "\C-cmh"         'html-mode)
(define-key global-map  "\C-cml"         'lsp-mode)
(define-key global-map  "\C-cmw"         'web-mode)
(define-key global-map  "\C-cmn"         'nxhtml-mode)
                                        ; (define-key global-map  "\C-cmx"         'nxml-mode) / somehow I press it sometimes in org-mode?
(define-key global-map  "\C-cmd"         'django-html-mumamo-mode)
(define-key global-map  "\C-cmc"         'conf-mode)
(define-key global-map  "\C-cmo"         'company-mode)
(define-key global-map  "\C-cms"         'speedbar)
(define-key global-map  "\C-cmf"         'display-fill-column-indicator-mode)
(define-key global-map  "\C-cmt"         'global-tab-line-mode)
; scroll-other-window alt->
; scroll-other-window-down alt-<


(defun show-trailing-whitespace ()
  (interactive)
  (setq show-trailing-whitespace t)
  )

(defun hide-trailing-whitespace ()
  (interactive)
  (setq show-trailing-whitespace nil)
  )


(global-set-key (kbd "C-z a") 'align-regexp)

(global-set-key [C-f1] 'call-last-kbd-macro)
(global-set-key (kbd "C-z !") 'call-last-kbd-macro)

(define-key global-map  "\C-zws"         'show-trailing-whitespace)
(define-key global-map  "\C-zwh"         'hide-trailing-whitespace)
(define-key global-map  "\C-zwd"         'delete-trailing-whitespace)
(defun my-whitespace-newline ()
  (interactive)
  (whitespace-mode t)
  (whitespace-newline-mode t)
  )
(define-key global-map  "\C-zwn"         'my-whitespace-newline)

                                        ;  AV: cua-paste-pop (or use "yank-pop") in reverse
                                        ; (global-set-key [(M shift y)] '(lambda () (interactive) (cua-paste-pop -1)))

                                        ;
;;(global-set-key (kbd "C-` qp") 'sql-postgres)
;;(global-set-key (kbd "C-` qm") 'sql-mysql)
(global-set-key (kbd "C-z t") 'proced)

(global-set-key (kbd "<C-Scroll_Lock>") 'scroll-lock-mode)
(global-set-key "\M- " 'hippie-expand)
(global-set-key (kbd "C-z l") 'display-line-numbers-mode)
(global-set-key (kbd "C-z s") 'whitespace-mode)
(global-set-key (kbd "C-c r") 'revert-buffer)
;; (global-set-key [(meta f5)] 'revert-buffer)
(global-set-key [(control shift f)] 'find-name-dired)
(define-key esc-map [f11] #'global-hl-line-mode)



;; (defun switch-to-sql ()
;;   (interactive)
;;   (switch-to-buffer '"*SQL*")
;; )
;; (global-set-key [(control f11)] 'switch-to-sql)

(global-set-key [(control f11)] 'scroll-bar-mode)

(defun just-insert-line-above ()
  (interactive)
  (setq c (current-column))
  (move-beginning-of-line 1)
  (newline)
  (move-to-column c)
  )

(global-set-key [ (control insert) ] 'kill-ring-save)
(global-set-key [ (control shift insert) ] 'just-insert-line-above)
(global-set-key [ (control +) ] 'just-insert-line-above)

(define-key global-map  "\C-zd"         'delete-whitespace-rectangle)

(define-key global-map  "\C-c'"         'electric-pair-mode)

                                        ; justify
(fset 'justify-region
      [menu ?s ?e ?t ?- ?j ?u ?s ?t tab return ?f tab return])
(define-key global-map  "\C-cj"         'justify-region)


(global-set-key [backtab] 'indent-according-to-mode)
(global-set-key (kbd "<mouse-8>") 'mouse-yank-at-point)
(global-set-key (kbd "C-z i") 'ibuffer)
(global-set-key (kbd "C-z r n") 'rename-buffer)

                                        ; this is for android devices, where Ctrl+Space is occupied by language
                                        ; switch
(define-key  global-map  "\C-zm"  'set-mark-command)


                                        ;(global-set-key [(control tab)] 'previous-buffer)
(global-set-key (kbd "C-z g") 'magit-status)
(global-set-key [S-f4] 'magit-status)

(define-key global-map (kbd "C-z c t") 'customize-themes)
(define-key global-map (kbd "C-z r r") 'revert-buffer)
(define-key global-map (kbd "C-c p k") 'projectile-kill-buffers)

;; (global-set-key [(control f4)] 'flycheck-mode)
(global-set-key (kbd "C-z e") 'zeal-at-point)
(global-set-key [(control escape)] 'delete-other-windows)


;; no idea where to place this function, let it hang here
(defun sort-lines-nocase ()
  (interactive)
  (let ((sort-fold-case t))
    (call-interactively 'sort-lines)))

(global-set-key (kbd "s-s L") 'sort-lines-nocase)


;; remap alt mouse wheel keys to generate Up/Down
(global-set-key [(meta mouse-4)] 'previous-line)
(global-set-key [(meta mouse-5)] 'next-line)
                                        ;
(global-set-key [(control mouse-4)] 'backward-paragraph)
(global-set-key [(control mouse-5)] 'forward-paragraph)
(global-set-key [(control mouse-8)] 'previous-buffer)
(global-set-key [(control mouse-9)] 'next-buffer)

;; (defun visit-magit-diff-file (event &optional promote-to-region)
;;   "Visit file by right mouse click at point in magit-diff."
;;   (interactive)
;;   (mouse-set-point)
;;   (magit-diff-visit-file)
;;   )

;; FIXME: need to mouse-set-point first
(defadvice magit-diff (after switch-to-diff activate)
  (local-set-key [mouse-3] 'magit-diff-visit-file))
;; (add-hook 'magit-diff-mode
;;           '(lambda ()
;;              (local-set-key [mouse-3] '(lamda ()
;;                                               (message "come here")
;;                                               (mouse-set-point)
;;                                               (magit-diff-visit-file)))
;;           ))


;; FIXME
;;(if (require 'gh-md nil 'noerror)
;;    (define-key markdown-mode-map (kbd "C-z r m") 'gh-md-render-buffer))



(defun toggle-frame-split ()
  "If the frame is split vertically, split it horizontally or vice versa.
 Assumes that the frame is only split into two."
  (interactive)
  (unless (= (length (window-list)) 2) (error "Can only toggle a frame split in two"))
  (let ((split-vertically-p (window-combined-p)))
    (delete-window) ; closes current window
    (if split-vertically-p
        (split-window-horizontally)
      (split-window-vertically)) ; gives us a split with the other window twice
    (switch-to-buffer nil))) ; restore the original window in this part of the frame

;; I don't use the default binding of 'C-x 5', so use toggle-frame-split instead
(global-set-key (kbd "C-x 5 t") 'toggle-frame-split)

                                        ; (global-set-key (kbd "C-x x") 'repeat)
(global-set-key (kbd "C-x z") 'ztree-dir)



(defun geosoft-kill-buffer ()
  "Kill default buffer without the extra questions."
  (interactive)
  (kill-buffer (buffer-name))
  )
(global-set-key [M-delete] 'geosoft-kill-buffer)

                                        ; (global-set-key (kbd "C-z C-z") 'suspend-frame)

(fset 'switch-to-tree
      [f9 ?s ?m ?s ?v escape ?< ?\C-s ?Z ?t ?r ?e ?e ?\C-a return])


(global-set-key (kbd "C-c C-t") 'switch-to-tree)
(global-set-key (kbd "s-s m") 'discover-my-major)

(defun insert-file-name ()
  "Insert current file name."
  (interactive)
  (insert (buffer-file-name (window-buffer (minibuffer-selected-window)))))

(defun insert-buffer-name ()
  "Insert current buffer name."
  (interactive)
  (insert (buffer-name (window-buffer (minibuffer-selected-window)))))
(global-set-key (kbd "C-c i f") 'insert-file-name)
(global-set-key (kbd "C-c i b") 'insert-buffer-name)

(defun mouse-yank-at-point (click)
  "Insert the primary selection at the position clicked on.
 Move point to the end of the inserted text, and set mark at
 beginning.  If `mouse-yank-at-point' is non-nil, insert at point
 regardless of where you click."
  (interactive "e")
  ;; Give temporary modes such as isearch a chance to turn off.
  (run-hooks 'mouse-leave-buffer-hook)
  ;; Without this, confusing things happen upon e.g. inserting into
  ;; the middle of an active region.
  (when select-active-regions
    (let (select-active-regions)
      (deactivate-mark)))
  (let ((primary (gui-get-primary-selection)))
    (push-mark (point))
    (insert-for-yank primary)))


(global-set-key [mouse-2] 'mouse-yank-at-point)


(defun shift-region (distance)
  (let ((mark (mark)))
    (save-excursion
      (indent-rigidly (region-beginning) (region-end) distance)
      (push-mark mark t t)
      ;; Tell the command loop not to deactivate the mark
      ;; for transient mark mode
      (setq deactivate-mark nil))))

(defun shift-right ()
  (interactive)
  (shift-region 1))

(defun shift-left ()
  (interactive)
  (shift-region -1))

;; Bind (shift-right) and (shift-left) function to your favorite keys. I use
;; the following so that Ctrl-Shift-Right Arrow moves selected text one
;; column to the right, Ctrl-Shift-Left Arrow moves selected text one
;; column to the left:

(global-set-key [(control <)] 'shift-left)
(global-set-key [(control >)] 'shift-right)

;;
;; speedbar and neotree
                                        ; (global-set-key [(meta f7)] 'sr-speedbar-toggle)
;; (global-set-key [(S-f3)] 'helm-fzf)
(global-set-key [(S-f3)] 'find-file)


(defun fit-window-to-buffer-width (&optional window max-width min-width)
  "Fit WINDOW according to its buffer's width.
 WINDOW, MAX-WIDTH and MIN-WIDTH have the same meaning as in
 `fit-window-to-buffer'."
  (interactive)
  (let ((fit-window-to-buffer-horizontally 'only))
    (fit-window-to-buffer window nil nil max-width min-width)))

;; https://emacs.stackexchange.com/questions/19126/auto-resize-window-widths-to-accomodate-line-length
(defun fit-window-to-buffer-width (&optional window max-width min-width)
  "Fit WINDOW according to its buffer's width.
 WINDOW, MAX-WIDTH and MIN-WIDTH have the same meaning as in
 `fit-window-to-buffer'."
  (interactive)
  (let ((fit-window-to-buffer-horizontally 'only))
    (fit-window-to-buffer window nil nil max-width min-width)))

(defun fit-window-to-buffer-height (&optional window max-height min-height)
  "Fit WINDOW according to its buffer's height.
 WINDOW, MAX-HEIGHT and MIN-HEIGHT have the same meaning as in
 `fit-window-to-buffer'."
  (interactive)
  (let ((fit-window-to-buffer-horizontally nil))
    (fit-window-to-buffer window max-height min-height nil nil)))

(defun fit-window-to-buffer-height-or-width
    (&optional window max-height min-height max-width min-width)
  "Fit WINDOW according to its buffer's height and width.
 WINDOW, MAX-HEIGHT, MIN-HEIGHT, MAX-WIDTH and MIN-WIDTH have the same meaning
 as in `fit-window-to-buffer'."
  (interactive)
  (let ((fit-window-to-buffer-horizontally t))
    (fit-window-to-buffer window max-height min-height max-width min-width)))

(global-set-key (kbd "C-x w w") 'fit-window-to-buffer-width)
(global-set-key (kbd "C-x w h") 'fit-window-to-buffer)

(fset 'org-insert-task-from-redmine
      [?\[ ?\[ ?\C-y ?\C-  C-left ?\M-w C-right ?\] ?\[ ?\C-y ?\] ?\]])

(fset 'close-frame-below
      [S-s-down ?\C-x ?0])
(fset 'close-frame-up
      [S-s-up ?\C-x ?0])
(fset 'close-frame-right
      [S-s-right ?\C-x ?0])
(fset 'close-frame-left
      [S-s-left ?\C-x ?0])
(global-set-key (kbd "C-x 9 d") 'close-frame-below)
(global-set-key (kbd "C-x 9 u") 'close-frame-up)
(global-set-key (kbd "C-x 9 l") 'close-frame-left)
(global-set-key (kbd "C-x 9 r") 'close-frame-right)

;; LastPass replacement - this macro will find password in my password storage and place it
;; into clipboard
(fset 'find-password
      [?\C-c ?a ?s ?\C-y return ?\C-s ?p ?a ?s ?s ?w ?d return return ?\C-z ?p ?p])

(defun copy-file-name-to-clipboard ()
  "Copy the current buffer file name to the clipboard."
  (interactive)
  (let ((filename (if (equal major-mode 'dired-mode)
                      default-directory
                    (buffer-file-name))))
    (when filename
      (kill-new filename)
      (message "Copied buffer file name '%s' to the clipboard." filename))))
(global-set-key (kbd "C-c F") 'copy-file-name-to-clipboard)

(defun xml-pretty-print (beg end &optional arg)
  "Reformat the region between BEG and END.
     With optional ARG, also auto-fill."
  (interactive "*r\nP")
  (let ((fill (or (bound-and-true-p auto-fill-function) -1)))
    (sgml-mode)
    (when arg (auto-fill-mode))
    (sgml-pretty-print beg end)
    (nxml-mode)
    (auto-fill-mode fill)))

;; (global-set-key (kbd "C-c x") 'xml-pretty-print)


(fset 'insert_org_fileref
      [?\C-x ?\C-s C-f9 ?\C-  ?\C-a ?m ?v ?  ?\C-y ?  ?. return ?\[ ?\[ ?f ?i ?l ?e ?: ?\C-u escape ?! ?b ?a ?s ?e ?n ?a ?m ?e ?  ?\C-y return ?\C-e ?\] ?\] ?\C-a ?\C-e return])

;; foward/backward whitespace
(global-set-key (kbd "M-F") 'forward-whitespace)

(fset 'replace_selected_with_clipboard
      [?\C-x ?r ?s ?1 ?\C-  ?\C-e ?\C-g ?\C-  C-left C-left C-left C-left ?\C-x ?\( ?\C-x ?r ?s ?1 ?\C-x ?b ?t ?e ?m ?p ?_ ?c ?l ?i ?b backspace ?p ?b ?o ?a ?r ?d ?. ?t ?m ?p return ?\C-y ?\C-  ?\C-a ?\C-w ?\C-x ?k return ?\C-a f7 ?\C-x ?r ?i ?1 return ?\C-y return ?\C-x])


(defun replace-selected-with-clipboard()
  "Replace marked with contents of x-clipboard.
 This happends quite often when I need to replace some string in my file
 with something already in clipboard."
  (interactive)
  (let ((emacs-selected (buffer-substring (mark) (point)))
        (x-clipboard (gui--selection-value-internal 'CLIPBOARD)))
    (when (not x-clipboard) (user-error "x-clipboard value is not set"))
    (when (not emacs-selected) (user-error "region is not selected"))
    (beginning-of-line)
    (query-replace emacs-selected x-clipboard)
    )
  )

(global-set-key (kbd "C-x 6 x") 'replace-selected-with-clipboard)

(global-set-key (kbd "M-g l") 'avy-goto-line)
(global-set-key (kbd "M-n") 'avy-goto-line)
(global-set-key [(f1)] 'avy-goto-line)

;(global-set-key "\C-z+" 'ivy-push-view)
;(global-set-key "\C-z-" 'ivy-pop-view)
(global-set-key "\C-z=" 'imenu-list)

(defalias 'close-other-window
  (kmacro "C-x o C-x 0"))

(global-set-key "\C-z0" 'close-other-window)

(defun my-clipboard-browse ()
  "Replacement of CopyQ and other clipboard managers"
  (interactive)
  (switch-to-buffer "*kill-ring-paste*")
  (erase-buffer)
  (helm-show-kill-ring)
  )

(defun switch-to-scratch()
  (interactive)
  (switch-to-buffer "*scratch*")
  )

;;  (global-set-key "\C-zs" 'switch-to-scratch)

htmlize

(use-package htmlize)

Duplicate line

I like this variation from http://stackoverflow.com/questions/88399/how-do-i-duplicate-a-whole-line-in-emacs because: it does not uses kill ring

   (defun jr-duplicate-line ()
     "EASY"
     (interactive)
     (save-excursion
	(let ((line-text (buffer-substring-no-properties
			  (line-beginning-position)
			  (line-end-position))))
	  (move-end-of-line 1)
	  (newline)
	  (insert line-text))))

   (global-set-key [(control =)] 'jr-duplicate-line) ;; Ctrl+

Lisp & paredit

(use-package paredit)
(add-hook 'lisp-mode-hook 'paredit-mode)

;; paredit autoload
(autoload 'enable-paredit-mode "paredit" "Turn on pseudo-structural editing of Lisp code." t)
(add-hook 'clojure-mode 'enable-paredit-mode)
(add-hook 'clojurescript-mode 'enable-paredit-mode)
(add-hook 'lisp-mode-hook 'paredit-mode)

;; Make the key no longer bound to paredit-forward-barf-sexp
(define-key paredit-mode-map (kbd "<C-left>") nil)

;; Make the key no longer bound to paredit-forward-slurp-sexp
(define-key paredit-mode-map (kbd "<C-right>") nil)

transparency

(defun enable-transparency ()
  (interactive)
  (set-frame-parameter (selected-frame) 'alpha '(92 97))
  (add-to-list 'default-frame-alist '(alpha 92 97))
  )

(defun disable-transparency ()
  (interactive)
  (set-frame-parameter (selected-frame) 'alpha '(100 100))
  (add-to-list 'default-frame-alist '(alpha 100 100))
  )

					    ; (enable-transparency)
(define-key global-map (kbd "C-z p 1") 'enable-transparency)
(define-key global-map (kbd "C-z p 2") 'disable-transparency)
(define-key global-map (kbd "C-z p 0") 'disable-transparency)

terraform-mode

(use-package terraform-mode)
(add-to-list 'auto-mode-alist '("\\.tf\\.j2\\'" . terraform-mode))

makefile-mode

(add-to-list 'auto-mode-alist '("Makefile\\.*" . makefile-mode))

my Favourite themes

(use-package ample-theme :defer t)
(use-package ample-zen-theme :defer t)
(use-package anti-zenburn-theme :defer t)
(use-package apropospriate-theme :defer t)
(use-package avk-emacs-themes :defer t)
(use-package base16-theme :defer t)
(use-package clues-theme :defer t)
(use-package color-theme-sanityinc-tomorrow :defer t)
(use-package creamsody-theme :defer t)
(use-package espresso-theme :defer t)
(use-package flatland-theme :defer t)
(use-package flatui-dark-theme :defer t)
(use-package flatui-theme :defer t)
(use-package inkpot-theme :defer t)
(use-package leuven-theme :defer t)
(use-package moe-theme :defer t)
(use-package panda-theme :defer t)
(use-package parchment-theme :defer t)
(use-package spacemacs-theme :defer t)
(use-package suscolors-theme :defer t)
(use-package tango-plus-theme :defer t)
(use-package tangotango-theme :defer t)
(use-package warm-night-theme :defer t)
(use-package darktooth-theme :defer t)
(use-package iodine-theme :defer t)
(use-package arjen-grey-theme :defer t)
(use-package birds-of-paradise-plus-theme :defer t)
(use-package bubbleberry-theme :defer t)
(use-package light-soap-theme :defer t)
(use-package ancient-one-dark-theme :defer t)
(use-package snazzy-theme :defer t)
(use-package twilight-bright-theme :defer t)
(use-package solo-jazz-theme :defer t)
(use-package dakrone-light-theme :defer t)
(use-package farmhouse-themes :defer t)
(use-package flucui-themes :defer t)
(use-package ef-themes :defer t)
(use-package monokai-theme :defer t)
(use-package zerodark-theme :defer t)
(use-package challenger-deep-theme :defer t)
(use-package humanoid-themes :defer t)
(use-package standard-themes :defer t)

clojure-mode and cider

(use-package flycheck-clj-kondo
  :ensure t)

(use-package clojure-mode
  :ensure t
  :mode (("\\.clj\\'" . clojure-mode)
         ("\\.edn\\'" . clojure-mode))
  :init
  (add-hook 'clojure-mode-hook #'yas-minor-mode)
  ;; (add-hook 'clojure-mode-hook #'linum-mode)
  (add-hook 'clojure-mode-hook #'subword-mode)
  ;; (add-hook 'clojure-mode-hook #'smartparens-mode)
  ;; (add-hook 'clojure-mode-hook #'rainbow-delimiters-mode)
  (add-hook 'clojure-mode-hook #'eldoc-mode)
  (add-hook 'clojure-mode-hook #'paredit-mode)
  :config
  (require 'flycheck-clj-kondo)
)
;; (add-hook 'clojure-mode-hook #'idle-highlight-mode)



;; (use-package clj-refactor)
;; (use-package cider
;;   :ensure t
;;   :defer t
;;   ;; :init (add-hook 'cider-mode-hook #'clj-refactor-mode)
;;   :diminish subword-mode
;;   :config
;;   (setq nrepl-log-messages t
;;         cider-repl-display-in-current-window t
;;         cider-repl-use-clojure-font-lock t
;;         cider-prompt-save-file-on-load 'always-save
;;         cider-font-lock-dynamically '(macro core function var)
;;         nrepl-hide-special-buffers t
;;         cider-overlays-use-font-lock t)
;;   (cider-repl-toggle-pretty-printing))

;; ;; LSP for clojure from htt
;; ps://clojure-lsp.io/clients/
;; (dolist (m '(clojure-mode
;;              clojurec-mode
;;              clojurescript-mode
;;              clojurex-mode))
;;   (add-to-list 'lsp-language-id-configuration `(,m . "clojure")))

clj-kondo

  (use-package flymake-kondor
    :ensure t
    :hook (clojure-mode . flymake-kondor-setup)
    :bind (([f6] . flymake-goto-next-error)
           ([S-f6] . flymake-goto-prev-error))
    :init
    (add-hook 'clojure-mode-hook #'flymake-mode)
    (add-hook 'clojure-mode-hook #'flymake-kondor-setup)
)

dap mode

https://github.com/emacs-lsp/dap-mode

(use-package dap-mode)
(add-hook 'dap-stopped-hook
          (lambda (arg) (call-interactively #'dap-hydra)))
(require 'dap-node)
;; (dap-node-setup)

compilation colors

(require 'ansi-color)
(defun colorize-compilation-buffer ()
  (ansi-color-apply-on-region compilation-filter-start (point-max)))
(add-hook 'compilation-filter-hook 'colorize-compilation-buffer)

typescript-mode

(add-to-list 'auto-mode-alist '("\\.ts" . typescript-mode))

projectile

Easy way to select file in your project.

(use-package projectile)
(use-package helm-projectile
  :init
  (projectile-global-mode)
  (setq projectile-enable-caching t)
  :bind (([(M-s-tab)] . helm-projectile-switch-to-buffer)
         ([(C-tab)] . helm-buffers-list)
         ("C-z C-z" . helm-projectile-switch-to-buffer)
         ("C-x C-<tab>" . helm-projectile-switch-to-buffer)
         ("C-c h p p" . helm-projectile)
         ("<f5>" . helm-projectile-find-file)
         ("C-c h p f" . helm-projectile-find-file)
         ("C-c h p s" . helm-projectile-switch-project)
         ("C-c p s" . projectile-switch-open-project)
         ("C-c h p r" . helm-projectile-recentf)
         ("C-c h p g" . helm-projectile-grep)
         ("C-c h p d" . helm-projectile-rg)
         ("M-<f5>" . projectile-find-file)
         )
  )

easy-kill

(use-package easy-kill
  :ensure t
  :config
  (global-set-key [remap kill-ring-save] #'easy-kill)
  (global-set-key [remap mark-sexp] #'easy-mark))

bm - bookmarks

(use-package bm
:bind (
("C-z b" . bm-toggle)
("C-z <up>" . bm-previous)
("C-z C-p" . bm-previous)
("C-z <down>" . bm-next)
("C-z C-n" . bm-next)
("C-z / 1" . my-bm-save-first-as-org-link)
("C-z / /" . my-bm-save-next-as-org-link)
("C-z / `" . my-bm-restore-bm)
([M-f1] . bm-show-all)
("C-z <SPC>" . bm-show-all)
)
;; :config
;; (setq-default bm-buffer-persistence t)
)

yesno

I am too lazy to answer β€˜yes’ and β€˜no’ in full notation, lets shortcut:

(fset 'yes-or-no-p 'y-or-n-p)

Enable ibuffer

(require 'ibuffer)
(global-set-key [f9]  'ibuffer)

Always display file name in frame title

http://www.emacswiki.org/emacs/FrameTitle display full file name in window title

This feature is not yet complete - since it seems org-mode looses current settings after clock-out.

(defun fix-frame-title ()
  (interactive)
  (setq frame-title-format
        '("%S" (buffer-file-name "%f"
                                 (dired-directory dired-directory "%b"))))
  )
(fix-frame-title)
;(add-hook 'after-make-frame-functions 'fix-frame-title)
(define-key global-map  "\C-cft" 'fix-frame-title)

ediff

Ediff - diffing framework within emacs. Some useful extensions here, like choosing both variants (frequent case), from http://stackoverflow.com/questions/9656311/conflict-resolution-with-emacs-ediff-how-can-i-take-the-changes-of-both-version

(defun ediff-copy-both-to-C ()
  (interactive)
  (ediff-copy-diff ediff-current-difference nil 'C nil
                   (concat
                    (ediff-get-region-contents ediff-current-difference 'A ediff-control-buffer)
                    (ediff-get-region-contents ediff-current-difference 'B ediff-control-buffer))))
(defun add-d-to-ediff-mode-map () (define-key ediff-mode-map "d" 'ediff-copy-both-to-C))
(add-hook 'ediff-keymap-setup-hook 'add-d-to-ediff-mode-map)

switch buffers

(fset 'cxb_switch_last_buffer
   (kmacro-lambda-form [?\C-x ?b return] 0 "%d"))

(global-unset-key (kbd "C-`"))
(global-set-key (kbd "C-`") 'cxb_switch_last_buffer)
(global-set-key (kbd "C-<iso-lefttab>") 'projectile-switch-to-buffer)

vterm

(use-package vterm
  :bind
  ("C-z k" . vterm)
  ; ([f2] . vterm)
  :config
  (define-key vterm-mode-map (kbd "<Scroll_Lock>")
  'vterm-copy-mode)
  )

 

web-mode

(use-package web-mode)

(setq web-mode-markup-indent-offset 2)
(setq web-mode-css-indent-offset 2)
(setq web-mode-code-indent-offset 2)
(setq web-mode-indent-style 2)
(add-to-list 'auto-mode-alist '("\\.html\\'" . web-mode))
(setq web-mode-engines-alist '(("django" . "\\.html\\'") ) )



(defun is_buffer_of (ext)
  (if (bufferp (current-buffer))
      (progn (setq buffer_name (buffer-file-name (current-buffer)))
             (if (stringp buffer_name)
                 (if (string-match ext buffer_name) t nil)
               nil))
      nil))



(add-hook 'web-mode-hook
          '(lambda ()
             (yas-minor-mode)
             (yas-activate-extra-mode 'web-mode)
             (display-line-numbers-mode)
             ;; (highlight-indentation-mode t)
             (when (is_buffer_of ".*\.vue$")
                 (tide-mode)
                 (company-mode)
                 (apheleia-mode +1)
                 )
             )
          )

;; ;; http://web-mode.org/
;; (add-hook 'web-mode-before-auto-complete-hooks
;;           '(lambda ()
;;              (let ((web-mode-cur-language
;;                     (web-mode-language-at-pos)))
;;                (if (string= web-mode-cur-language "django")
;;                    (progn
;;                      (message "web-mode: we are here")
;;                      (yas-activate-extra-mode 'web-mode)
;;                      (yas-minor-mode))
;;                  (message "web-mode: not there")
;;                  ))))

(fset 'macro-insert-trans
   (lambda (&optional arg) "Keyboard macro." (interactive "p") (kmacro-exec-ring-item '([23 116 114 97 110 115 tab tab return 25] 0 "%d") arg)))

tide & typescript mode

https://github.com/ananthakumaran/tide

  (use-package typescript-mode)
  (use-package tide
    :ensure t
    :after (typescript-mode)
    ;;:hook ((typescript-mode . tide-setup)
;;	   (typescript-mode . flycheck-mode)
;;	   (typescript-mode . tide-hl-identifier-mode))
    ;; 	 ;; (before-save . tide-format-before-save)
    ;; 	 )
    )


  (defun setup-tide-mode ()
    (interactive)
    (tide-setup)
    (flycheck-mode +1)
    (setq flycheck-check-syntax-automatically '(save mode-enabled))
    (eldoc-mode +1)
    (tide-hl-identifier-mode +1)
    (apheleia-mode +1)
    ;; company is an optional dependency. You have to
    ;; install it separately via package-install
    ;; `M-x package-install [ret] company`
    (flycheck-add-next-checker 'typescript-tide 'javascript-eslint 'append)
    (company-mode +1))

  ;; aligns annotation to the right hand side
  (setq company-tooltip-align-annotations t)

  ;; formats the buffer before saving
  ;; (add-hook 'before-save-hook 'tide-format-before-save)

  (defun my-enable-tide ()
    (interactive)
    (add-hook 'typescript-mode-hook #'setup-tide-mode)
    (add-hook 'tsx-ts-mode-hook #'setup-tide-mode)
    )

  (defun my-disable-tide ()
    (interactive)
    (remove-hook 'typescript-ts-mode-hook #'setup-tide-mode)
    (remove-hook 'tsx-ts-mode-hook #'setup-tide-mode)
    )
(my-enable-tide)

company mode

While its in conflict with lsp-bridge, this mode is still very useful in some cases, e.g. shell etc

(use-package company)

publish file

(defun my-publish-file()
  (interactive)
  (async-shell-command "my-publish-file")
  )

persistent keymap

https://karthinks.com/software/persistent-prefix-keymaps-in-emacs/

(defun repeated-prefix-help-command ()
  (interactive)
  (when-let* ((keys (this-command-keys-vector))
	       (prefix (seq-take keys (1- (length keys))))
	       (orig-keymap (key-binding prefix 'accept-default))
	       (keymap (copy-keymap orig-keymap))
	       (exit-func (set-transient-map keymap t #'which-key-abort)))
    (define-key keymap [remap keyboard-quit]
      (lambda () (interactive) (funcall exit-func)))
    (which-key--create-buffer-and-show nil keymap)))

(setq prefix-help-command #'repeated-prefix-help-command)

eslint for tide

    ;; (flycheck-add-mode 'javascript-eslint 'typescript-mode)
    ;; (with-eval-after-load 'flycheck
    ;;   (flycheck-add-mode 'javascript-eslint 'typescript-mode))


  ;; https://github.com/hlissner/doom-emacs/issues/1530#issuecomment-507653761
  ;; (add-hook 'after-typescript-mode-hook
  ;;           (lambda ()
  ;;             (flycheck-add-next-checker 'typescript-tide 'javascript-eslint 'append)))
  ;;   (flycheck-add-next-checker 'python-flake8 'python-pylint)
;;(flycheck-add-next-checker 'typescript-tide 'javascript-eslint 'append)

flycheck, flymake

(use-package flycheck
  :ensure t
  :config
  (global-flycheck-mode t)
  (flycheck-add-mode 'javascript-eslint 'typescript-mode)
  ;; note that these bindings are optional
  :bind
  ([C-f8] . flycheck-list-errors)
  )
(use-package flycheck-pycheckers
  :after flycheck
  :ensure t
  :init
  (with-eval-after-load 'flycheck
    (add-hook 'flycheck-mode-hook #'flycheck-pycheckers-setup)
    )
  (setq flycheck-pycheckers-checkers
	'(
	  pylint
	  pyflakes
	  mypy3
	  )
	)
  )

;; (add-hook 'python-ts-mode-hook
;; 	  (setq indent-tabs-mode nil)
;; 	  (setq tab-width 4)
;; 	  (flycheck-mode)
;; 	  )
(add-hook 'python-ts-mode-hook #'flycheck-mode)

conf-mode

(add-to-list 'auto-mode-alist '("\\.env" . conf-mode))

feature-mode

for cucumber / gherkin tests

(use-package feature-mode)

Aphelia

(use-package apheleia
  :bind (("\C-cmA" . apheleia-mode)))
(require 'apheleia-formatters)
(setf (alist-get 'isort apheleia-formatters)
      '("isort" "--stdout" "-"))
(setf (alist-get 'python-mode apheleia-mode-alist)
      '(isort))

ox-gfm

(use-package ox-gfm)

ident space

also read: https://stackoverflow.com/questions/27731433/setting-per-project-indent-variables-in-emacs

(setq-default indent-tabs-mode nil)

sgml / mailgun

(add-to-list 'auto-mode-alist '("\\.mjml" . sgml-mode))

marginalia

(use-package marginalia
  ;; Bind `marginalia-cycle' locally in the minibuffer.  To make the binding
  ;; available in the *Completions* buffer, add it to the
  ;; `completion-list-mode-map'.
  :bind (:map minibuffer-local-map
         ("M-A" . marginalia-cycle))

  ;; The :init section is always executed.
  :init

  ;; Marginalia must be activated in the :init section of use-package such that
  ;; the mode gets enabled right away. Note that this forces loading the
  ;; package.
  (marginalia-mode))

python auto virtualenv for python-ts-mode

(use-package auto-virtualenv
  :ensure t
  :init
  (use-package pyvenv
    :ensure t)
  :config
  (add-hook 'python-ts-mode-hook 'auto-virtualenv-set-virtualenv)
  (add-hook 'python-mode-hook 'auto-virtualenv-set-virtualenv)
  (add-hook 'projectile-after-switch-project-hook 'auto-virtualenv-set-virtualenv)
  )

helm-systemd

(use-package helm-systemd)

straight

(defvar bootstrap-version)
(let ((bootstrap-file
       (expand-file-name
        "straight/repos/straight.el/bootstrap.el"
        (or (bound-and-true-p straight-base-dir)
            user-emacs-directory)))
      (bootstrap-version 7))
  (unless (file-exists-p bootstrap-file)
    (with-current-buffer
        (url-retrieve-synchronously
         "https://raw.githubusercontent.com/radian-software/straight.el/develop/install.el"
         'silent 'inhibit-cookies)
      (goto-char (point-max))
      (eval-print-last-sexp)))
  (load bootstrap-file nil 'nomessage))
(setq frame-resize-pixelwise t)

dape

(use-package dape
  ;; To use window configuration like gud (gdb-mi)
  ;; :init
  ;; (setq dape-buffer-window-arrangement 'gud)

  :config
  ;; Info buffers to the right
  (setq dape-buffer-window-arrangement 'right)

  ;; To not display info and/or buffers on startup
  ;; (remove-hook 'dape-on-start-hooks 'dape-info)
  ;; (remove-hook 'dape-on-start-hooks 'dape-repl)

  ;; To display info and/or repl buffers on stopped
  (add-hook 'dape-on-stopped-hooks 'dape-info)
  (add-hook 'dape-on-stopped-hooks 'dape-repl)

  ;; By default dape uses gdb keybinding prefix
  ;; If you do not want to use any prefix, set it to nil.
  (setq dape-key-prefix "\C-x\C-a")

  ;; Kill compile buffer on build success
  (add-hook 'dape-compile-compile-hooks 'kill-buffer)

  ;; Save buffers on startup, useful for interpreted languages
  ;; (add-hook 'dape-on-start-hooks
  ;;           (defun dape--save-on-start ()
  ;;             (save-some-buffers t t)))

  ;; Projectile users
  (setq dape-cwd-fn 'projectile-project-root)
  )

dirvish

(use-package dirvish
  )

org-mind-map

;; the headings of an org file
(use-package org-mind-map
  :init
  (require 'ox-org)
  :ensure t
  ;; Uncomment the below if 'ensure-system-packages` is installed
  ;;:ensure-system-package (gvgen . graphviz)
  :config
  (setq org-mind-map-engine "dot")       ; Default. Directed Graph
  ;; (setq org-mind-map-engine "neato")  ; Undirected Spring Graph
  ;; (setq org-mind-map-engine "twopi")  ; Radial Layout
  ;; (setq org-mind-map-engine "fdp")    ; Undirected Spring Force-Directed
  ;; (setq org-mind-map-engine "sfdp")   ; Multiscale version of fdp for the layout of large graphs
  ;; (setq org-mind-map-engine "twopi")  ; Radial layouts
  ;; (setq org-mind-map-engine "circo")  ; Circular Layout
  )

tab-line

see also https://github.com/thread314/intuitive-tab-line-mode

(global-set-key (kbd "s-<prior>") 'tab-line-switch-to-prev-tab)
(global-set-key (kbd "s-<next>") 'tab-line-switch-to-next-tab)
(use-package tab-line
  :init
  (defvar-keymap tab-line-mode-map
    :doc "Keymap for keys of `tab-line-mode'."
    "C-x C-<left>"  #'tab-line-switch-to-prev-tab
    "C-x C-<right>" #'tab-line-switch-to-next-tab)
  )

;;(global-set-key (kbd "s-<wheel-left>")  #'tab-line-switch-to-prev-tab)
;;(global-set-key (kbd "s-<wheel-right>") #'tab-line-switch-to-next-tab)

;; (global-set-key (kbd "C-S-<prior>") 'tab-line-switch-to-prev-tab)
;; (global-set-key (kbd "C-S-<next>") 'tab-line-switch-to-next-tab)
;; (global-set-key (kbd "C-S-w") 'tab-line-close-tab)

;; (use-package intuitive-tab-line
;;   :load-path "lisp/intuitive-tab-line-mode"
;;   :custom
;;   (tab-line-tabs-function 'intuitive-tab-line-buffers-list)
;;   (tab-line-switch-cycling t)
;;   :config
;;   (global-tab-line-mode 1)
;;   (recentf-mode 1)
;;   (setq
;;    tab-line-new-button-show nil  ;; do not show add-new button
;;    tab-line-close-button-show nil  ;; do not show close button
;;    tab-line-separator " "  ;; delimitation between tabs
;;    ))

;; ;;(global-set-key (kbd "C-<tab>") 'tab-line-switch-to-next-tab)
;; (global-set-key (kbd "C-S-<prior>") 'intuitive-tab-line-shift-tab-left)
;; (global-set-key (kbd "C-S-<next>") 'intuitive-tab-line-shift-tab-right)
;; ;;(global-set-key (kbd "C-S-t") 'recentf-open-most-recent-file)

next/prev buffer

(global-set-key (kbd "C-z <right>") 'next-buffer)
(global-set-key (kbd "C-z <left>") 'previous-buffer)

window management

(global-set-key (kbd "C-s-<down>") 'enlarge-window)
(global-set-key (kbd "C-s-<up>") 'shrink-window)
;; (global-set-key (kbd "C-s-<right>") 'enlarge-window-horizontally)
;; (global-set-key (kbd "C-s-<left>") 'shrink-window-horizontally)

emacs calc

(use-package casual
  :ensure t
  :bind (:map calc-mode-map ("C-o" . 'casual-main-menu)))

consult imenu

(global-set-key [S-f2]  'consult-imenu)
(add-to-list 'consult-imenu-config
             '(python-mode
               :toplevel "Function"
               :types
               ((?f "Function" font-lock-function-name-face)
                (?m "Method" font-lock-function-name-face)
                (?c "Class" font-lock-property-use-face)
                (?M "Module" font-lock-builtin-face)
                (?F "Field" font-lock-regexp-face)
                (?v "Variable" font-lock-constant-face))))

(global-set-key [M-f7] 'consult-ripgrep)

counsel-ag

(use-package counsel-ag-popup
  :ensure t
  :bind ("C-c M-c" . 'counsel-ag))

minimap

Lets try it (again), but I found that it does not work well in org-mode for example.

(use-package minimap
  :ensure t)
(define-key esc-map [f12] #'minimap-mode)

dired-casual

(use-package casual-dired
:ensure t
:bind (:map dired-mode-map ("C-o" . 'casual-dired-tmenu)))

dslide

;; package-vc
;; (package-vc-install
;;  '(dslide
;;    :url "https://github.com/positron-solutions/dslide.git"))

jtsx

(use-package jtsx
  :ensure t
  :mode (("\\.jsx?\\'" . jtsx-jsx-mode)
         ("\\.tsx\\'" . jtsx-tsx-mode)
         ;; ("\\.ts\\'" . jtsx-typescript-mode)
         )
  :commands jtsx-install-treesit-language
  :hook ((jtsx-jsx-mode . hs-minor-mode)
         (jtsx-tsx-mode . hs-minor-mode)
         (jtsx-typescript-mode . hs-minor-mode))
  :custom
  ;; Optional customizations
  (js-indent-level 2)
  ;; (typescript-ts-mode-indent-offset 2)
  ;; (jtsx-switch-indent-offset 0)
  ;; (jtsx-indent-statement-block-regarding-standalone-parent nil)
  ;; (jtsx-jsx-element-move-allow-step-out t)
  ;; (jtsx-enable-jsx-electric-closing-element t)
  ;; (jtsx-enable-electric-open-newline-between-jsx-element-tags t)
  ;; (jtsx-enable-jsx-element-tags-auto-sync nil)
  ;; (jtsx-enable-all-syntax-highlighting-features t)
  :config
  (defun jtsx-bind-keys-to-mode-map (mode-map)
    "Bind keys to MODE-MAP."
    (define-key mode-map (kbd "C-c C-j") 'jtsx-jump-jsx-element-tag-dwim)
    (define-key mode-map (kbd "C-c j o") 'jtsx-jump-jsx-opening-tag)
    (define-key mode-map (kbd "C-c j c") 'jtsx-jump-jsx-closing-tag)
    (define-key mode-map (kbd "C-c j r") 'jtsx-rename-jsx-element)
    (define-key mode-map (kbd "C-c <down>") 'jtsx-move-jsx-element-tag-forward)
    (define-key mode-map (kbd "C-c <up>") 'jtsx-move-jsx-element-tag-backward)
    (define-key mode-map (kbd "C-c C-<down>") 'jtsx-move-jsx-element-forward)
    (define-key mode-map (kbd "C-c C-<up>") 'jtsx-move-jsx-element-backward)
    (define-key mode-map (kbd "C-c C-S-<down>") 'jtsx-move-jsx-element-step-in-forward)
    (define-key mode-map (kbd "C-c C-S-<up>") 'jtsx-move-jsx-element-step-in-backward)
    (define-key mode-map (kbd "C-c j w") 'jtsx-wrap-in-jsx-element)
    (define-key mode-map (kbd "C-c j u") 'jtsx-unwrap-jsx)
    (define-key mode-map (kbd "C-c j d") 'jtsx-delete-jsx-node)
    (define-key mode-map (kbd "C-c j t") 'jtsx-toggle-jsx-attributes-orientation)
    (define-key mode-map (kbd "C-c j h") 'jtsx-rearrange-jsx-attributes-horizontally)
    (define-key mode-map (kbd "C-c j v") 'jtsx-rearrange-jsx-attributes-vertically))

  (defun jtsx-bind-keys-to-jtsx-jsx-mode-map ()
    (jtsx-bind-keys-to-mode-map jtsx-jsx-mode-map))

  (defun jtsx-bind-keys-to-jtsx-tsx-mode-map ()
    (jtsx-bind-keys-to-mode-map jtsx-tsx-mode-map))

  (add-hook 'jtsx-jsx-mode-hook 'jtsx-bind-keys-to-jtsx-jsx-mode-map)
  (add-hook 'jtsx-tsx-mode-hook 'jtsx-bind-keys-to-jtsx-tsx-mode-map))

move-text

(use-package move-text
  :ensure t
  :bind (
         ("M-<up>" . move-text-up)
         ("M-<down>" . move-text-down)
         )
  )

verb

  (use-package verb)
  (with-eval-after-load 'org
    (define-key org-mode-map (kbd "C-c C-r") verb-command-map))
;; (org-babel-do-load-languages
;;  'org-babel-load-languages
;;  '((verb . t)))

org-babel sql

(org-babel-do-load-languages
 'org-babel-load-languages
 '((sql . t)))

consult-omni

(global-unset-key (kbd "C-x /"))
(use-package consult-omni
  :straight (consult-omni :type git :host github :repo "armindarvish/consult-omni" :branch "main" :files (:defaults "sources/*.el"))
  :after consult
  :bind (
         ("C-x / p f f" . consult-omni-fieldhub)
         ("C-x / p f j" . consult-omni-fieldhub-jira-task)
         ("C-x / p f b" . consult-omni-fieldhub-bitbucket-prs))
  ;;:custom
  ;; General settings that apply to all sources
  ;;(consult-omni-show-preview t) ;;; show previews
  ;;(consult-omni-preview-key "C-o") ;;; set the preview key to C-o
  ;; :config
  )
;; Load Sources Core code
(require 'consult-omni-sources)
(require 'consult-omni-apps)
(require 'consult-omni-browser-history)
(require 'consult-omni-buffer)
(require 'consult-omni-calc)
(require 'consult-omni-grep)
(require 'consult-omni-gptel)
(require 'consult-omni-elfeed)
(require 'consult-omni-ripgrep)
(require 'consult-omni-notmuch)
(require 'consult-omni-org-agenda)

(consult-omni-define-source "FieldHub Jira task"
                            :type 'sync
                            :request
                            #'my-fh-jira-task-results)

(defun my-fh-jira-task-results (input &rest args)
  "return jira task link"
  (let ((jira_url (concat "https://fieldhub.atlassian.net/browse/" input))
        (bitbucket_search_url (concat "https://bitbucket.org/fieldhub/fh-urbase/pull-requests/?state=OPEN&query=" input))
        )
    (list 
     (propertize (format "Bitbucket search %s" bitbucket_search_url) :url bitbucket_search_url)
     (propertize (format "Jira %s" jira_url) :url jira_url)  ;; first result - link to Jira task itself
     )
    )
  )

 (consult-omni-define-source "FieldHub Bitbucket PRs"
                             :type 'sync
                             :request
                             #'my-fh-open-bitbucket-prs)

 (defun my-fh-open-bitbucket-prs (input &rest args)
   "bitbucket PR"
       (let ((url-request-method "GET")
           (url-request-extra-headers (list (cons "Authorization" fieldhub-basic-auth)))
           (url "https://api.bitbucket.org/2.0/repositories/fieldhub/fh-urbase/pullrequests"))
       (with-current-buffer (url-retrieve-synchronously url)
         (goto-char (point-min))
         (re-search-forward "\n\n" nil 'noerror)
         (delete-region (point-min) (point))
         (let* ((json-result (lsp-json-read-buffer))
                (values (gethash "values" json-result))
                (titles (delq nil (mapcar (lambda (val) (let* ((title (gethash "title" val))
                                                               (links (gethash "links" val))
                                                               (html_link (gethash "href" (gethash "html" links)))
                                                               ) (if (string-match (concat ".*" input ".*") title) (propertize title :url html_link) nil))) values)))
                )
           titles
           )))
       )

(defun consult-omni-fieldhub (&optional initial
                                        al no-callback &rest args)
  "My omni"
  (interactive "P")
  (let ((consult-async-split-style 'comma))
    (consult-omni-multi initial "🌍 :" '("ripgrep" "notmuch") no-callback args)))

some mouse bindings

(global-set-key (kbd "s-<mouse-1>")  'split-window-below)
(global-set-key (kbd "s-<mouse-3>")  'split-window-right)
(global-set-key (kbd "s-<drag-mouse-3>")  'delete-window)
(global-set-key (kbd "s-<drag-mouse-1>")  'geosoft-kill-buffer)

pgmacs

https://github.com/emarsden/pgmacs.git

(use-package pgmacs
  :load-path "~/.emacs.d/lisp/pgmacs/"
  :init 
  (unless (package-installed-p 'pg)
    (package-vc-install "https://github.com/emarsden/pg-el" nil nil 'pg))
  (unless (package-installed-p 'pgmacs)
    (package-vc-install "https://github.com/emarsden/pgmacs"))
  (require 'pgmacs))

large files

Do not ask for confirmation for opening large file, because Helm will freeze with follow mode enabled (TBD report a bug?)

(defun files--ask-user-about-large-file (size op-type filename offer-raw)
  "Query the user about what to do with large files.
Files are \"large\" if file SIZE is larger than `large-file-warning-threshold'.

OP-TYPE specifies the file operation being performed on FILENAME.

If OFFER-RAW is true, give user the additional option to open the
file literally."
  'raw)

camel case

(use-package string-inflection)
(global-set-key (kbd "C-c _") 'string-inflection-cycle)
;; (global-set-key (kbd "C-c C") 'string-inflection-camelcase)        ;; Force to CamelCase
;; (global-set-key (kbd "C-c L") 'string-inflection-lower-camelcase)  ;; Force to lowerCamelCase
;; (global-set-key (kbd "C-c J") 'string-inflection-java-style-cycle) ;; Cycl

org-pdftools

I often want to link to my own comment in a PDF file. Here is the approach to do this

(use-package org-pdftools)

About

My emacs config

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published