You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
(defunninrod/return-t-advice (old-function&restarguments)
"Make the old-function return t in any case."
(apply old-function arguments)
t)
please don’t kill my precious scratch buffer
;; credits to stefan monier (GNU Emacs mantainer);; http://lists.gnu.org/archive/html/help-gnu-emacs/2017-02/msg00074.html
(with-current-buffer (get-buffer"*scratch*")
(add-hook'kill-buffer-hook
(lambda () (error"DENIED! don't kill my precious *scratch*!!"))
nilt)) ;; Append at the end of the hook list? no. Buffer-local? yes.
(defunninrod/advice-delete-frame (dumb-delete-frame&restarguments)
"test an advice around delete frame"
(when (yes-or-no-p"are you sure you want to delete the emacs frame?")
(apply dumb-delete-frame arguments)))
;; (advice-add #'delete-frame :around #'ninrod/advice-delete-frame)
iBuffer
(defunninrod/ibuffer-recent-buffer (old-ibuffer&restarguments) ()
"Open ibuffer with cursor pointed to most recent buffer name"
(let ((recent-buffer-name (buffer-name)))
(apply old-ibuffer arguments)
(ibuffer-jump-to-buffer recent-buffer-name)))
(advice-add#'ibuffer:around#'ninrod/ibuffer-recent-buffer)
better windows splits
(defunninrod/split-window-below-and-focus ()
"Split the window vertically and focus the new window."
(interactive)
(split-window-below)
(windmove-down))
(defunninrod/split-window-right-and-focus ()
"Split the window horizontally and focus the new window."
(interactive)
(split-window-right)
(windmove-right))
(defunninrod/terminal/copy-to-clipboard ()
"When in terminal, copies selection to x-clipboard."
(interactive)
(cond ((and (region-active-p) (not (display-graphic-p)))
(shell-command-on-region (region-beginning) (region-end) "xsel -i -b")
(message"Yanked region to clipboard through terminal!")
(deactivate-mark))
(t (message"No region active; can't yank to clipboard!"))))
(defunninrod/terminal/paste-from-clipboard ()
"When in terminal, pastes from x-clipboard."
(interactive)
(cond ((display-graphic-p)
(clipboard-yank)
(message"Graphics active, no need to use xclip."))
(t (insert (shell-command-to-string"xsel -o -b")))))
environment
ninrod–distro-p
(defunninrod--distro-p (distro)
"verify if we are on DISTRO at the moment."
(string-match distro (shell-command-to-string"uname -a")))
(defunninrod/revert-buffer-no-confirm ()
"Revert buffer without confirmation."
(interactive)
(revert-buffer:ignore-auto:noconfirm))
ninrod/alternate-buffer
(defunninrod/alternate-buffer ()
"Switch to previously open buffer.Repeated invocations toggle between the two most recently open buffers."
(interactive)
(switch-to-buffer (other-buffer (current-buffer) 1)))
toggle display absolute line number on the current line
(defunninrod/toggle-absolute-current-relative-visual-line-number ()
"Toogle showing absolute line number or 0 for the current line when display-line-numbers is set to visual or relative"
(interactive)
;; tip from Stefan Monier;; http://lists.gnu.org/archive/html/emacs-devel/2017-07/msg00099.html;; do I have to (require 'cl-macs) here?
(cl-callf not display-line-numbers-current-absolute))
(defunninrod/eval-print-last-sexp ()
"Move point to the end of the line and eval-prints last sexp."
(interactive)
(save-excursion
(goto-char (point-at-eol))
(eval-print-last-sexp)))
ninrod/eval-last-sexp
(defunninrod/eval-last-sexp ()
"Move point to the end of the line and eval last sexp."
(interactive)
(save-excursion)
(goto-char (point-at-eol))
(eval-last-sexpnil))
(defunninrod/echo ()
"just a simple test message for use within bind setups"
(interactive)
(message"The new bind *WORKED*! Yes!!11!"))
ninrod/add-to-hooks
;; from https://github.com/cofi/dotfiles/blob/master/emacs.d/config/cofi-util.el#L38
(defunninrod/add-to-hooks (funhooks)
"Add function to hooks."
(dolist (hook hooks)
(add-hook hook fun)))
(defunninrod/org-eol-m-ret ()
"Moves point to the end of the line and applies m-ret and enters insert state."
(interactive)
(goto-char (point-at-eol))
(org-meta-return)
(evil-insert-state))
(defunninrod/org-bol-m-ret ()
"Same as ninrod/org-eol-m-ret, but now at beggining of the line. This two could be a single parameterized function if I weren't such a piece of shit elisp programmer."
(interactive)
(goto-char (point-at-bol))
(org-meta-return)
(evil-insert-state))
(defunninrod/org-insert-subheading ()
"evil style org-insert-subheading"
(interactive)
(goto-char (point-at-eol))
(org-insert-subheadingnil)
(evil-insert-state))
(defunninrod/org-insert-heading-respect-content ()
"evil style org-insert-subheading"
(interactive)
(goto-char (point-at-eol))
(org-insert-heading-respect-content)
(evil-insert-state))
(defunninrod/org-mv-down () ; moves a value down
(interactive)
(let ((pos (point)) ; get current pos
(f (org-table-get-field))) ; copy current field
(org-table-blank-field) ; blank current field
(org-table-next-row) ; move cursor down
(org-table-blank-field) ; blank that field too
(insert f) ; insert the value from above
(org-table-align) ; realign the table
(goto-char pos))) ; move back to original position
(defunninrod/org-swap-down () ; swap with value below
(interactive)
(let ((pos (point)) ; get current pos
(v1 (org-table-get-field))) ; copy current field
(org-table-blank-field) ; blank current field
(org-table-next-row) ; move cursor down
(let ((v2 (org-table-get-field))) ; take copy of that field, too
(org-table-blank-field) ; blank that field too
(insert v1) ; insert the value from above
(goto-char pos) ; go to original location
(insert v2) ; insert the value from below
(org-table-align) ; realign the table
(goto-char pos)))) ; move back to original position
just use the json-pretty-print that comes with emacs
spacemacs/align-repeat
;; modified function from http://emacswiki.org/emacs/AlignCommands
(defunspacemacs/align-repeat (startendregexp&optionaljustify-rightafter)
"Repeat alignment with respect to the given regular expression.If JUSTIFY-RIGHT is non nil justify to the right instead of theleft. If AFTER is non-nil, add whitespace to the left instead ofthe right."
(interactive"r\nsAlign repeat regexp: ")
(let* ((ws-regexp (if (string-empty-p regexp)
"\\(\\s-+\\)""\\(\\s-*\\)"))
(complete-regexp (if after
(concat regexp ws-regexp)
(concat ws-regexp regexp)))
(group (if justify-right -11)))
(message"complete-regexp: %S" complete-regexp)
(align-regexp start end complete-regexp group 1t)))
(defunninrod/reverse-region (begend)
"Reverse characters between BEG and END."
(interactive"r")
(let ((region (buffer-substring beg end)))
(delete-region beg end)
(insert (nreverseregion))))
evil
bootstrap
(use-package evil
:ensuret:init
(use-package goto-chg :ensuret)
(use-package undo-tree :ensuret)
(use-package evil-test-helpers :ensuret)
(setq evil-want-integration t;; This is optional since it's already set to t by default.
evil-want-keybinding nil)
:config
(setcdr evil-insert-state-map nil) ;; emacsify insert state: http://stackoverflow.com/a/26573722/4921402
(define-key evil-insert-state-map [escape] 'evil-normal-state) ;; but [escape] should switch back to normal state, obviously.
(fset'evil-visual-update-x-selection'ignore) ;; Amazing hack lifted from: http://emacs.stackexchange.com/a/15054/12585
(setq evil-want-change-word-to-end nil
evil-kill-on-visual-paste nil
evil-want-keybinding nil)
(evil-mode 1)
(evil-set-command-property 'evil-yank:move-pointt)
(evil-define-text-object ninrod/textobj-entire (count&optional beg end type)
(evil-range (point-min) (point-max))) ;; simulation of kana's textobj-entire
(define-key evil-outer-text-objects-map "e"'ninrod/textobj-entire))
(use-package evil-collection
:after evil
:ensuret:config
(evil-collection-init))
babysited packages
targets.el
this is the way to add new text-objects without targets.el
;; modified to be able to specify name and use `function'
(defmacrodefine-and-bind-quoted-text-object (namekeystart-regexend-regex)
(let ((inner-name (make-symbol (concat"evil-inner-" name)))
(outer-name (make-symbol (concat"evil-a-" name))))
`(progn
(evil-define-text-object ,inner-name (count&optional beg end type)
(evil-select-paren ,start-regex,end-regex beg end type count nil))
(evil-define-text-object ,outer-name (count&optional beg end type)
(evil-select-paren ,start-regex,end-regex beg end type count t))
(define-key evil-inner-text-objects-map ,key#',inner-name)
(define-key evil-outer-text-objects-map ,key#',outer-name))))
(define-and-bind-quoted-text-object "pipe""|""|""|")
(define-and-bind-quoted-text-object "slash""/""/""/")
(define-and-bind-quoted-text-object "dollar""$""\\$""\\$")
(setq backup-directory-alist
`((".". ,(expand-file-name
(concat user-emacs-directory "backups")))))
(setq vc-make-backup-files t) ;Make backups of files, even when they're in version control
(setq auto-save-default nil) ;stop creating those #auto-save# files
(global-auto-revert-mode)
(when (display-graphic-p)
(when (eq system-type 'darwin)
;; start maximized;; (set-frame-parameter nil 'fullscreen 'fullboth);; (toggle-frame-maximized);; osx does not lose screen real state with menu bar mode on
(menu-bar-mode1)))
(fset'yes-or-no-p'y-or-n-p)
(setq recentf-max-menu-items 200;; MRU configs
recentf-max-saved-items 200
recentf-exclude '("recentf""autoload""emacs-customizations.el")
default-directory "~/.dotfiles"
initial-scratch-message ";; -*- lexical-binding: t -*-\n;; scratch buffer.\n\n"
inhibit-startup-message t
display-time-default-load-average nil
display-time-day-and-date t
save-interprogram-paste-before-kill t;; Save whatever’s in the clipboard before replacing it with the Emacs’ text.
yank-pop-change-selection t;; https://github.com/dakrone/eos/blob/master/eos.org;; confirm-kill-emacs #'y-or-n-p ;; ask before killing emacs
echo-keystrokes 0.02) ;; instantly display current keystrokes in mini buffer
(set-default'truncate-linest)
(display-time-mode) ;; hack: customize display time in modeline.
(save-place-mode1) ;; save last cursor position
(savehist-mode1) ;; save minibuffer history
(tool-bar-mode-1)
(menu-bar-mode-1)
(electric-pair-mode1)
(column-number-modet)
(recentf-mode1)
(if (fboundp'scroll-bar-mode) ;; for emacs compiled with `nox'
(scroll-bar-mode-1))
(setq org-capture-templates
'(("a""My TODO task format." entry
(file "~/code/sources/gtd/inbox.org")
"* TODO %? ")))
(defunninrod/org-task-capture ()
"Capture a task with my default template."
(interactive)
(org-capturenil"a"))
(setq org-agenda-files '("~/code/sources/gtd/"))
(defunninrod/pop-to-org-agenda (&optionalsplit)
"Visit the org agenda, in the current window or a SPLIT."
(interactive"P")
(org-agendanil"d")
(when (not split)
(delete-other-windows)))
(defunninrod/org-skip-subtree-if-priority (priority)
"Skip an agenda subtree if it has a priority of PRIORITY.PRIORITY may be one of the characters ?A, ?B, or ?C."
(let ((subtree-end (save-excursion (org-end-of-subtreet)))
(pri-value (*1000 (- org-lowest-priority priority)))
(pri-current (org-get-priority (thing-at-point'linet))))
(if (= pri-value pri-current)
subtree-end
nil)))
(defunninrod/org-skip-subtree-if-habit ()
"Skip an agenda entry if it has a STYLE property equal to \"habit\"."
(let ((subtree-end (save-excursion (org-end-of-subtreet))))
(if (string= (org-entry-getnil"STYLE") "habit")
subtree-end
nil)))
(setq org-agenda-custom-commands
'(("d""Daily agenda and all TODOs"
((tags "PRIORITY=\"A\""
((org-agenda-skip-function '(org-agenda-skip-entry-if 'todo'done))
(org-agenda-overriding-header "High-priority unfinished tasks:")))
(agenda "" ((org-agenda-ndays 1)))
(alltodo ""
((org-agenda-skip-function '(or (ninrod/org-skip-subtree-if-habit)
(ninrod/org-skip-subtree-if-priority ?A)
(org-agenda-skip-if nil '(scheduled deadline))))
(org-agenda-overriding-header "ALL normal priority tasks:"))))
((org-agenda-compact-blocks t)))))
(setq org-agenda-text-search-extra-files '(agenda-archives))
the projectile-switch-project-action hack was lifted from here.
(use-package projectile :ensuret:init;; (add-hook 'after-init-hook 'projectile-mode)
(use-package counsel-projectile :ensuret)
;; use ivy
(setq projectile-completion-system 'ivy)
;; make projectile usable for every directory
(setq projectile-require-project-root nil)
;; cd into dir i want, including git-root;; (defun cd-dwim ();; (cd (projectile-project-root)));; (setq projectile-switch-project-action 'cd-dwim):config
(projectile-global-mode)
:diminish global-projectile-mode "")
neotree
(use-package neotree
:ensuret:init
(setq neo-create-file-auto-open t
neo-auto-indent-point nil
neo-mode-line-type 'none
neo-window-fixed-size nil
neo-theme 'icons
neo-window-width 40
neo-show-updir-line nil
neo-smart-open t
neo-show-hidden-files t
neo-banner-message nil))
(use-package disable-mouse
:ensure t
:config
(when (not (or (ninrod--distro-p "ubuntu")
(ninrod--distro-p "linuxkit")))
(global-disable-mouse-mode)
(define-key evil-motion-state-map [down-mouse-1] 'ignore) ;; don't jump the cursor around in the window on clicking
(define-key evil-motion-state-map [mouse-1] 'ignore)) ;; also avoid any '<mouse-1> is undefined' when setting to 'undefined
:diminish disable-mouse-global-mode)
cucumber
(use-package feature-mode
:ensure t)
go
(use-package go-mode
:ensure t
:config
(add-hook 'before-save-hook 'gofmt-before-save))
(use-package go-eldoc
:ensure t
:config
(add-hook 'go-mode-hook 'go-eldoc-setup))
(use-package go-guru
:ensure t)
(general-define-key
:keymaps'motion:prefix"g";; "." 'reserved;; "/" 'reserved;; "RET" 'reserved;; "m" 'reserved;; "0" 'reserved"TAB"'counsel-mark-ring"o"'evil-goto-first-line"l"'evil-goto-line"m"'ninrod/evil-goto-marker-z"h"'counsel-recentf"s"'magit-status"i"'goto-last-change";"'evil-last-non-blank"+"'evil-numbers/inc-at-pt"-"'evil-numbers/dec-at-pt;; As I've sequestered < and > when in org mode, we need a workaround.">"'evil-shift-right"<"'evil-shift-left
)
(general-define-key
:keymaps '(normal visual motion)
:prefix"g""a"'evil-lion-left"A"'evil-lion-right
)
(org-t-map
;; "<SPC>" 'ninrod/org-insert-subheading ; open new subheading"l"'org-metaright"h"'org-metaleft"j"'org-metadown"k"'org-metaup"y"'ninrod/org-retrieve-url-from-point"n"'org-narrow-to-subtree"t"'org-todo"-"'org-ctrl-c-minus"*"'org-ctrl-c-star"p"'org-priority"TAB"'ninrod/org-insert-subheading; open new subheading"o"'ninrod/org-eol-m-ret; open new heading below, not respecting content"RET"'ninrod/org-insert-heading-respect-content; open new heading below, respecting content"DEL"'ninrod/org-bol-m-ret; open new heading above"i"'org-tree-to-indirect-buffer
)
(org-T-map
"t"'org-table-transpose-table-at-point"h"'org-backward-sentence"l"'org-forward-sentence"d"'org-table-delete-column"f"'org-table-edit-formulas;; from https://www.reddit.com/r/emacs/comments/56oc9c/orgtables_is_there_a_way_to_delete_a_whole_table/;; fist place point in the top left bar (`|')"m"'org-mark-element"o"'org-table-insert-row; above"i"'org-table-insert-column;before;; formulas"@"'org-table-toggle-coordinate-overlays"?"'org-table-field-info"e" '((lambda () (interactive) ; [E]val formulas
(let ((current-prefix-arg4))
(call-interactively'org-table-recalculate))) :which-key"eval formulas")
"RET"'org-table-copy-down
)
;; (setq dired-listing-switches "-lhXA --group-directories-first")
(with-eval-after-load'dired
(ninrod/dired--unbinds)
(evil-make-overriding-map dired-mode-map 'normalt); use the standard Dired bindings as a base
(ninrod/dired--binds))
(lisp-t-map
"o"'ninrod/eval-print-last-sexp;; mnemonic: output to current buffer"k"'lispyville-drag-backward"j"'lispyville-drag-forward)
(lisp-comma-map
"e"'eval-defun"d"'ninrod/uarg-eval-defun;; instrument func with edebug"b"'eval-buffer"h"'lispy-describe-inline)
(general-define-key
:keymaps'ag-mode-map"s"nil"g"nil"n"nil"N"nil"r"'recompile"DEL"'compilation-previous-error;; TAB is already bound to compilation-next-error"<SPC>"nil)