Skip to content

Instantly share code, notes, and snippets.

View sheijk's full-sized avatar

Jan R sheijk

View GitHub Profile
@sheijk
sheijk / config.yaml
Created April 3, 2021 13:07
evdevremapper systemd service on nixos
devices:
- input_name: 'AT Translated Set 2 keyboard'
output_name: 'AT Translated Set 2 keyboard remapped'
remappings:
# Fix key right of left shift
KEY_102ND:
- KEY_GRAVE
# more omitted as it doesn't change the issue
@sheijk
sheijk / functions.el
Last active January 26, 2021 22:05
A simple menu to change text (upper/lower case, incr numbers, move parenthesis, replace inner/outer)
(defun my-increment-number-decimal (&optional arg)
"Increment the number forward from point by 'arg'."
(interactive "p*")
(save-excursion
(save-match-data
(let (inc-by field-width answer)
(setq inc-by (if arg arg 1))
(skip-chars-backward "0123456789")
(when (re-search-forward "[0-9]+" nil t)
(setq field-width (- (match-end 0) (match-beginning 0)))
@sheijk
sheijk / shk-jump-menu.el
Created January 26, 2021 22:00
A simple menu to move point to places on screen
;; Warning, code ripped from config, might not work as is
(require 'transient)
(require 'windmove)
(require 'window-numbering)
(require 'avy)
(defun shk-has-window-numbered (i)
"Return whether there is a window numbered `i' by window-numbering.el"
(let ((windows (car (gethash (selected-frame) window-numbering-table))))
(and (>= i 0) (< i 10)
@sheijk
sheijk / shk-toggle-menu.el
Created January 26, 2021 21:56
A menu to toggle a few common modes, showing a way to make toggle w/o -/= prefix
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Toggling options
;;
;; This is using the following conventions:
;; - single keys activates local mode/option
;; - global version is prefixed with g and the same key
(defun shk-flyspell-or-prog-mode ()
(interactive)
(if flyspell-mode
@sheijk
sheijk / shk-start-menu.el
Last active January 26, 2021 22:03
A simple menu to start a few apps from Emacs, including convenient profiler toggle
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Quickly start applications, etc.
(defun shk-open-buffer-in-atom ()
"Will open the given buffer using the Atom text editor."
(interactive)
(unless (buffer-file-name)
(error "Buffer has no file associated"))
(async-shell-command (format "atom %s" (buffer-file-name))))
@sheijk
sheijk / projectile-menu.el
Created January 26, 2021 21:49
Emacs projectile menu using transient
;; Simple menu for projectile using transient from my personal config
(transient-define-prefix shk-projectile-menu ()
"A menu for projectile"
[["Project"
("p" "switch to" projectile-switch-project)
("q" "… opened" projectile-switch-open-project)
("k" "close" projectile-kill-buffers)
("S" "save all" projectile-save-project-buffers)
("v" "version control" projectile-vc)
("E" "edit dir locals" projectile-edit-dir-locals)
@sheijk
sheijk / gist:1512400
Created December 23, 2011 00:03
Simple way of moving private non-virtual methods out of .h
// -----------------------------------------------------------------------------
// in foo.h
#ifndef FOO_H_2011_12_23_INCLUDED
#define FOO_H_2011_12_23_INCLUDED
class Foo
{
friend class FooImpl;