Skip to content

Instantly share code, notes, and snippets.

View Dima-369's full-sized avatar
🥒
Juicing celery!

Dima Dima-369

🥒
Juicing celery!
View GitHub Profile
@Dima-369
Dima-369 / emacs.el
Last active May 5, 2021 19:43
Old avy config (with tuned avy-goto-char-timer-own which restarts on no matches like on typos) in Emacs Lisp
;; this should better be handled via (advice-add)
(defun avy-handler-default (char)
"The default handler for a bad CHAR."
(let (dispatch)
(cond ((setq dispatch (assoc char avy-dispatch-alist))
(unless (eq avy-style 'words)
(setq avy-action (cdr dispatch)))
(throw 'done 'restart))
((memq char avy-escape-chars)
(setq avy-cancelled-via-escape t)
@Dima-369
Dima-369 / emacs.el
Created April 8, 2021 20:11
Old org-superstar package config (I feel that is slows down org-mode a bit so I don't use it anymore)
(use-package org-superstar
:custom
(org-superstar-remove-leading-stars t)
(org-superstar-headline-bullets-list '("◉" "○" "●" "○" "●" "○" "●"))
:config
(add-hook 'org-mode-hook
(lambda ()
(org-superstar-mode 1))))
@Dima-369
Dima-369 / emacs.el
Last active March 31, 2021 19:03
Unfinished emmet-mode setup and some utilities for web-mode in Emacs Lisp
(defun is-in-web-modes ()
(or (string= major-mode "web-mode")
(string= major-mode "sgml-mode")
(string= major-mode "mhtml-mode")
(string= major-mode "css-mode")))
(defun emmet-enter-insert-mode (arg)
(interactive "P")
(xah-fly-insert-mode-activate))
@Dima-369
Dima-369 / emacs.el
Created February 24, 2021 19:18
Use (buffer-file-name) with (intern) to dynamically create and access symbols entirely from strings in Emacs Lisp
(defun get-symbol-for-buffer-file ()
(intern (concat "jump-list-" (buffer-file-name))))
;; (message "%s" (intern "abcd"))
;; (message "%s" (boundp (intern "tab-width")))
(set (get-symbol-for-buffer-file) 369)
(message "%s" (symbol-value (get-symbol-for-buffer-file)))
@Dima-369
Dima-369 / emacs.el
Created February 13, 2021 09:44
Emacs auto-dim-other-buffers package config (not used anymore because the package always likes to turn itself back on)
;; to never dim the which-key frame and the deadgrep window
(defun mpn-never-dim-hidden (buf)
(or (string-match-p (regexp-quote "*deadgrep ") (buffer-name buf))
(eq ?\s (aref (buffer-name buf) 0)))
(add-hook 'auto-dim-other-buffers-never-dim-buffer-functions #'mpn-never-dim-hidden)
(add-hook 'after-init-hook (lambda ()
(when (fboundp 'auto-dim-other-buffers-mode)
(auto-dim-other-buffers-mode t))))
@Dima-369
Dima-369 / emacs.el
Last active February 24, 2021 19:16
Redefining keys for Emacs Lispy to a more xah-fly-keys right hand WASD layout for Programmer Dvorak
(defun setup-lispy ()
(add-hook 'emacs-lisp-mode-hook (lambda () (lispy-mode 1)))
(add-hook 'scheme-mode-hook (lambda () (lispy-mode 1)))
;; apparently setting tuhdo-special key-theme does not work
(eval-after-load "lispy"
`(progn
;; h is already mapped correctly to lispy-left
;; overwrites lispy-clone, was k
@Dima-369
Dima-369 / init.lua
Last active February 7, 2021 18:54
Open 2 Finder windows side by side in Hammerspoon
-- using real hyper with shift breaks some hotkeys for whatever reason
hyper = {"cmd", "alt", "ctrl"}
-- workaround from https://github.com/Hammerspoon/hammerspoon/issues/2099#issuecomment-490503167
function execAppleScript(scpt)
local scpt = 'run script ((POSIX file "' .. scpt .. '") as alias)'
hs.osascript.applescript(scpt)
end
hs.hotkey.bind(hyper, "n", function()
@Dima-369
Dima-369 / init.lua
Created February 7, 2021 18:41
Take a screenshot of the current window, save to /Desktop and open Finder in Hammerspoon
-- using real hyper with shift breaks some hotkeys for whatever reason
hyper = {"cmd", "alt", "ctrl"}
-- Take a screenshot of the current window
hs.hotkey.bind(hyper, "d", function()
file_name = "screenshot-" .. os.time() .. ".png"
hs.window.focusedWindow():snapshot():saveToFile(os.getenv("HOME") .. "/Desktop/" .. file_name)
title = hs.window.focusedWindow():title()
hs.alert.show(title .. "\n\n Saved screenshot as " .. file_name)
hs.execute('open ~/Desktop/')