Skip to content

Latest commit

 

History

History
1541 lines (1409 loc) · 51.5 KB

config_archive_2024.org

File metadata and controls

1541 lines (1409 loc) · 51.5 KB

Archived entries from file /home/yantar92/Git/emacs-config/config.org

2024

2024-07 July

2024-07-03 Wednesday

Archived Tasks

Show last commit in Git repos

Credit: [[id:Reddit:planetemacs_/u/negativeoilprice2021show_hide_emacs_dired_detail_in_stylebeb][/u/negativeoilprice [Reddit:planetemacs] (2021) Show/hide Emacs dired details in style]]

(use-package dired-git-info
  :if init-flag
  :straight t
  :bind (:map dired-mode-map
              (")" . dired-git-info-mode)))
Narrowing \ live filter dired-narrow

Credit: Dynamically filter directory listing with dired-narrow | Pragmatic Emacs Repo: [[id:Github-fuco1-fuco1-dired-hacks-707][Fuco1 [Github] Fuco1/dired-hacks: Collection of useful dired additions]]

(use-package dired-narrow
  :if init-flag
  :straight t
  :bind (:map dired-mode-map
              ("/" . dired-narrow)))
Search via helm
  • Note taken on [2021-09-21 Tue 20:21]
    I am not really using it
(use-package helm
  :if init-flag
  :defer t
  :config
  (use-package helm-notmuch
    :after notmuch
    :straight t))
auto-save-buffers-enhanced
[2020-09-24 Thu] This does not work well with large org buffers, especially with my config, which is auto-tangled on save. Better auto save.
(use-package auto-save-buffers-enhanced
  :straight t
  :config
  (auto-save-buffers-enhanced t))
Show file changes in the fringe
  • Refiled on [2020-09-24 Thu 21:20]
This slows down emacs on saving large org buffers. Disabling
(use-package git-gutter-fringe+
  :if init-flag
  :straight t
  :diminish git-gutter+-mode
  :init
  (use-package fringe-helper)
  :config
  (global-git-gutter+-mode))
Highlight uncommitted changes in version-controlled files and dirs
  • Refiled on [2020-09-24 Thu 21:21]

It slows down large org files though. Not going to use.

(use-package git-gutter-fringe
  :if init-flag
  :straight t
  :init
  (setq git-gutter-fr:side 'right-fringe)
  :config
  (add-hook 'magit-mode-hook #'git-gutter-mode))
Execute current buffer (c++,python,bash,…)
  • Refiled on [2020-09-24 Thu 21:21]
(use-package quickrun
  :if init-flag
  :straight t
  :bind (
	 ("<f10>" . quickrun)
	 ("<C-XF86Search>" . quickrun-with-arg)
	 ("<C-M-XF86Search>" . quickrun-shell)
	 ("<C-XF86Explorer>" . quickrun-region)
	 ("<C-M-XF86Explorer>" . quickrun-replace-region)
	 ("<f12>" . helm-quickrun)))
Wind move
  • Refiled on [2020-09-24 Thu 21:21]
(use-package boon
  :if init-flag
  :config
  (bind-keys :map boon-forward-search-map
	     ("j" . windmove-down)
             ("k" . windmove-up)
             ("i". windmove-left)
             ("o" . windmove-right)
             ("l" . other-window)
             :map boon-backward-search-map
	     ("j" . windmove-down)
             ("k" . windmove-up)
             ("i". windmove-left)
             ("o" . windmove-right)
	     ("l" . other-window)))
Show recursive directory size
  • Refiled on [2020-09-24 Thu 21:21]
(use-package dired-du
  :if init-flag
  :straight t
  :diminish dired-du-mode
  :custom
  ;; human readable size
  (dired-du-size-format t))
Do not use mouse
  • Refiled on [2020-09-24 Thu 21:22]
[2020-05-28 Thu] This interferes with pdf-view annoyingly. Easier to disable mouse globally when needed.

I can force no mouse in emacs (see emacswiki). Note that it does not interfere with pdf-tools.

(when init-flag
    (mouse-avoidance-mode 'banish))
Company completion
[2020-09-25 Fri] This prevents completing the account name Source: [[id:github_debanjum_deban_compan_ledger][debanjum [Github] Debanjum Company-Ledger]]
(use-package company-ledger
  :if init-flag
  :straight (company-ledger :host github :repo "debanjum/company-ledger")
  :after company
  :init
  (add-to-list 'company-backends 'company-ledger))
Never save some buffers
[2020-09-24 Thu] Seems to be fixed I got an issue with org-src block editing buffers. They are saved under some weird name beside the actual org file when some command, saving all the buffers, is executed.
(defvar yant/never-save-buffer-list nil
  "The buffers, matching any of the regexps in this list will never be saved.")
Warning when I try to send a message mentioning attachments in text, but without actual attachments
[2020-09-26 Sat] Use notmuch built-in system instead
(use-package message-attachment-reminder
  :if init-flag
  :straight t)
Preview screenshot on mouse hover

T to start generation

https://github.com/TheAMM/mpv_thumbnail_script

git clone $url
cd mpv_thumbnail_script
make
cp mpv_thumbnail_script_server.lua ~/.config/mpv/scripts/
cp mpv_thumbnail_script_client_osc.lua ~/.config/mpv/scripts/
Allow more space for the function name in profiler report
[2021-01-03 Sun] They actually changed it on master Credit: #email -> Alan Mackenzie <[email protected]> A tip: how to display longer function names in profiler-report
(use-package profiler
  :init
  (setq profiler-report-cpu-line-format '((70 left)
					  (14 right ((9 right) (5 right))))))
Fixing slow org priority regexp
[2021-03-13 Sat] Should be fixed on master
(setq org-priority-regexp "^\\*+.*\\(\\[#\\([A-Z0-9]+\\)\\] ?\\)")
Use [[id:Github-dandavison-dandavison-delta-viewer-c9d][dandavison [Github] dandavison/delta: A viewer for git and diff output]] to show diffs
  • Note taken on [2021-08-13 Fri 15:09]
    Performance is too low on large diffs (like in Org files)

[[id:Github-dandavison-github-dandavison-magit-213][dandavison [Github] dandavison/magit-delta: Use delta (https://github.com/dandavison/delta) when viewing diffs in Magit]]

Gentoo: dev-util/git-delta

(use-package magit-delta
  :straight t
  :after magit
  :hook (magit-mode . magit-delta-mode))
Archive logbook
Credit: https://www.reddit.com/r/orgmode/comments/dg43hs/can_i_archive_a_property_drawer/f3frk2n/
(defun my/org-archive-delete-logbook ()
  (save-excursion
   (org-end-of-meta-data)
   (let ((elm (org-element-at-point)))
     (when (and
            (equal (org-element-type elm) 'drawer)
            (equal (org-element-property :drawer-name elm) "LOGBOOK"))
       (delete-region (org-element-property :begin elm)
                      (org-element-property :end elm))))))

(defun my/org-archive-without-delete ()
  (cl-letf (((symbol-function 'org-cut-subtree) (lambda () nil)))
    (org-archive-subtree)))

(defun my/org-archive-logbook ()
  (interactive)
  (my/org-archive-without-delete)
  (my/org-archive-delete-logbook))
FAILED Use git for backups: helm-backup
  • Note taken on [2021-08-22 Sun 16:38]
    I do not like that it is using ediff
(use-package helm-backup
  :straight t
  :hook (after-save-hook . helm-backup-versioning))
FAILED Sorting with dired-quick-sort
  • State “FAILED” from [2021-08-27 Fri 21:48]
    Does not play well with dired hide dotfiles
(use-package dired-quick-sort
  :if init-flag
  :straight t
  :after diredp
  :init
  (setq dired-quick-sort-suppress-setup-warning nil)
  :config
  (dired-quick-sort-setup))
org-graph-view
  • Note taken on [2021-08-28 Sat 14:06]
    Looks cool, but too messy on large complex files

Requires =media-gfx/graphviz=: LaTeX for diagrams

(use-package org-graph-view
  :if init-flag
  :straight (org-graph-view :host github :repo "alphapapa/org-graph-view"))
Integrate languagetool with flycheck
  • Note taken on [2021-10-04 Mon 16:56]
    This is checking whole buffer - inefficient on large buffers
(use-package flycheck-languagetool
  :if init-flag
  :straight t
  :custom
  (flycheck-languagetool-server-jar nil))
Inline documentation in tooltip
  • Note taken on [2021-12-26 Sun 21:01]
    too large for my screen
(use-package company-quickhelp
  :straight t
  :if init-flag
  :after company
  :config
  (company-quickhelp-mode +1))
define-word at point
  • Note taken on [2022-02-20 Sun 15:18]
    format is not very good
(use-package define-word
  :if init-flag
  :straight t
  :custom
  (define-word-default-service 'offline-wikitionary)
  (define-word-offline-dict-directory "/home/yantar92/.emacs.d/dictionaries_enwiktionary_ding_20200401")
  :config
  (bind-key ";" #'define-word-at-point boon-goto-map))
Icons helm-icons
  • Note taken on [2022-03-18 Fri 22:40]
    There is now built-in helm-ff-icon-mode
(use-package helm-icons
  :straight t
  :if init-flag
  :after helm
  :custom
  (helm-icons-provider 'all-the-icons)
  (helm-icons-mode->icon
   '((dired-mode . "file-directory")))
  :config
  (helm-icons-enable))
Record point movement history beyond mark-ring gumshoe

[[id:Github-overdr0ne-overdr0ne-gumshoe-0c9][Overdr0ne [Github] Overdr0ne/gumshoe]]

(use-package gumshoe
  :if init-flag
  :straight t
  :diminish 'global-gumshoe-mode
  :init
  (global-gumshoe-mode +1)
  :config
  (bind-key "n" #'gumshoe-buf-backtrack-back boon-command-map)
  (bind-key "m" #'gumshoe-buf-backtrack-forward boon-command-map)
  (bind-key "M-n" #'gumshoe-backtrack-back)
  (bind-key "M-m" #'gumshoe-backtrack-forward)
  (bind-key "m" #'gumshoe-peruse-globally boon-goto-map))
Find emacs lisp definitions (elisp-def)
(use-package elisp-def
  :straight t
  :if init-flag
  :init
  (dolist (hook '(emacs-lisp-mode-hook ielm-mode-hook))
    (add-hook hook #'elisp-def-mode)))
Remind me about adding Woof headers when sending messages to org-mode maillist
  • Note taken on [2022-05-26 Thu 20:21]
    Woof will not support X-Woof-* headers in future releases. No need in this

Making sure to conform to Bastein’s request asking to use Woof conventions when sending emails. [[id:74d229fc782c20a7f32a04f07863af51598994b5][[Github] woof: Watch Over Our Folders]]

(use-package notmuch
  :if init-flag
  :defer t
  :config
  (defun yant/notmuch-mua-woof-check-maybe ()
    "Remind to use Woof headers when sending email to org-mode maillist."
    (let ((case-fold-search t))
      (save-excursion
	(goto-char (point-min))
	(when (re-search-forward "^\\(To:\\|Cc:\\).+emacs-orgmode@gnu\\.org" nil t)
          (goto-char (point-min))
          (unless (re-search-forward "^X-Woof-\\(Bug\\|Help\\|Change\\|Release\\|Patch\\):" nil t)
            (unless (yes-or-no-p "No Woof-(Bug|Help|Patch): t/nil headers found in message being sent to [email protected]. Send anyway? ")
	      (error "Forgot Woof headers")))))))
  (add-hook 'notmuch-mua-send-hook #'yant/notmuch-mua-woof-check-maybe))
Speed up agenda by caching some built-in functions
  • Note taken on [2022-06-08 Wed 12:18]
    These functions are now fast enough using org-element-cache. Calculating buffer hash is actually slowing things down.
(memoize-by-buffer-contents #'org-get-buffer-tags)
;; (memoize-by-buffer-contents #'org-refresh-category-properties)
;; (memoize-by-buffer-contents #'org-refresh-effort-properties)
Telegram
(use-package telega
  :straight t
  :custom
  (telega-server-libs-prefix "/home/yantar92/.local")
  :config
  (define-key global-map (kbd "C-c t") telega-prefix-map)
  (unbind-key "l" telega-msg-button-map)
  (unbind-key "L" telega-msg-button-map)
  (meta-defun meta-down :mode telega-root-mode telega-button-forward)
  (meta-defun meta-up :mode telega-root-mode telega-button-backward)
  (meta-defun meta-down-element :mode telega-chat-mode telega-button-forward)
  (meta-defun meta-up-element :mode telega-chat-mode telega-button-backward))
Opening repository file in remote browse-at-remote
  • Note taken on [2024-04-25 Thu 20:19]
    I am not really using it
(use-package browse-at-remote
  :if init-flag
  :straight t
  :config
  (bind-key "C-x M-o" #'browse-at-remote))
Persistent profiling

Emacs provides an excelled profiler via M-x profiler-start M-x profiler-report. However, it has a disadvantage - you need to know in advance that some slowness is about to happen. If the profiler is started too early, a lot of recorded information will be useless and, more importantly, shadow the actual slowdown of interest.

The solution is tripping the profiler data periodically on timer. This way, only last minutes of the profiling will be shown even if the profiler is running continuously.

(if init-flag
    (defvar yant/profiler--start-time (current-time)
      "Starting time of the last profiler call.")
  (defvar yant/profiler-max-time (* 60 5)
    "Maximum time allowed for profiler to run continuously.")
  (defun yant/profiler-restart-maybe ()
    "Restart profiler running for too long.
Too long is defined by `yant/profiler-max-time'."
    (when (and (or (profiler-cpu-running-p)
		   (profiler-memory-running-p))
	       (> (float-time (time-since yant/profiler--start-time))
		  yant/profiler-max-time))
      (setq yant/profiler--start-time (current-time))
      (cond
       ((and (profiler-cpu-running-p)
	     (profiler-memory-running-p))
        (profiler-stop)
        (profiler-start 'cpu+mem))
       ((profiler-cpu-running-p)
        (profiler-stop)
        (profiler-start 'cpu))
       ((profiler-memory-running-p)
        (profiler-stop)
        (profiler-start 'mem)))
      (message "Profiler restarted.")))
  (run-with-timer 1 yant/profiler-max-time #'yant/profiler-restart-maybe))
Journal
  • State “NEXT” from [2018-10-23 Tue 18:50]
  • Note taken on [2024-06-10 Mon 10:12]
    Alas, ain’t working in practice

Sometimes, I do some trial tasks for my projects or just try random things with programming. These things are unlikely to go into my actual notes or projects files. Not always though. It is always frustrating when I remember trying something and want to move it to actual notes of project file, but lose what I did.

Journal seems to be a good solution for it. I can dump all kind of staff there instead of having it spread over the bash history or just lost. I can write notes, run shell commands, calculations, etc without loosing what I have done. I may not even need to run terminal in such a case!

I have tried org-journal, but it does not really work for me because it creates too many files. A simple date-tree capture works just fine.

(use-package org-capture
  :if init-flag
  :after org
  :requires org
  :config
  (defvar yant/org-journal-file "~/Org/Journal.org"
    "Filename of the journal file")
  (use-package doct
    :defer t
    :config
    (setf
     (alist-get "j" org-capture-templates nil nil #'equal)
     (cdar (doct '("Journal entry"
		   :keys "j"
		   :type entry
		   :file yant/org-journal-file
		   :datetree t
		   :clock-in t
		   :clock-resume t
		   :jump-to-captured t
		   :template
		   ("* %?"
		    ":PROPERTIES:"
		    "CREATED: %U"
		    ":END:\n")))))))
Disable terminal key aliases (I don’t use console emacs anyway)
  • Note taken on [2024-06-20 Thu 08:48]
    disabling the aliases is problematic in practice - is makes it impossible to use C-m keymap prefix (in magit commit, C-m v is used to set version)

Source: https://www.reddit.com/r/emacs/comments/auwzjr/weekly_tipstricketc_thread/ehcg919/

(when init-flag
  ;; free up blocked keys (GUI only)
  ;; add to your init.el
  (define-key input-decode-map [?\C-m] [C-m])
  (define-key input-decode-map [?\C-i] [C-i])
  ;; https://debbugs.gnu.org/cgi/bugreport.cgi?bug=55672
  ;; (define-key input-decode-map (kbd "C-[") [C-\[])
  )
Saving web pages into notes
  • State “DONE” from “NEXT” [2018-09-06 Thu 20:53]
  • State “TODO” from [2017-12-30 Sat 22:20]

Sometimes, I want to save certain interesting online articles to disk to make sure that all the content and comments are preserved regardless of the website changes.

2024-07-22 Monday

Archived Tasks

Chinese input
(use-package pyim 
  :if init-flag
  :straight t
  :demand t
  :config
  (setq default-input-method "pyim")
  (setq-default pyim-english-input-switch-functions
		  '(pyim-probe-isearch-mode
		    pyim-probe-program-mode
		    pyim-probe-org-structure-template)))