Skip to content

Instantly share code, notes, and snippets.

@sg2002
sg2002 / sh-smie--indent-continuation.el
Last active September 6, 2021 17:51
Improved version of sh-smie--indent-continuation that on sh-indent-after-continuation = t indents past the beggining of the line variable path
(defun sh-smie--indent-continuation ()
(cond
((not (and sh-indent-after-continuation
(save-excursion
(ignore-errors
(skip-chars-backward " \t")
(sh-smie--looking-back-at-continuation-p)))))
nil)
((eq sh-indent-after-continuation 'always)
(save-excursion
@sg2002
sg2002 / scratch.el
Created June 14, 2017 22:50
Org custom skip by list
(defvar mylist '("Test"))
(defun my-skip-unless-in-list ()
"Skip unelss heading name is in list"
(ignore-errors
(let ((subtree-end (save-excursion (org-end-of-subtree t)))
(heading (nth 4 (org-heading-components))))
(if (not (member heading mylist))
subtree-end
nil))))
@sg2002
sg2002 / inc-apply.el
Created November 11, 2016 00:08
Applying a form with quoted args?
(defun inc (var)
(set var (+ 1 (symbol-value var))))
(setq x 1)
(inc 'x)
;; => 2
(inc x)
;; => (wrong-type-argument symbolp 2)
@sg2002
sg2002 / thread-cps.el
Last active October 26, 2016 16:14
thread-cps macro
(defmacro mwb-thread-cps (&rest forms)
"Thread FORMS elements wrapping each subsequent form into a lambda
passed as the last argument into a prior form."
`(funcall (mwb-thread-cps-impl ,(reverse forms))))
(defmacro mwb-thread-cps-impl (forms &optional k)
"Internal implementation for `mwb-thread-cps'."
(pcase forms
(`(,f . ,rest)
`(mwb-thread-cps-impl ,rest
@sg2002
sg2002 / time-subtract.el
Created October 10, 2016 13:42
Time-subtract weirdness
(let ((start-time (current-time)))
(sit-for 4)
(let ((end-time (current-time)))
(message "started: %s fininshed: %s after: %s"
(format-time-string "%T" start-time)
(format-time-string "%T" end-time)
(format-time-string "%T" (time-subtract end-time start-time)))))
@sg2002
sg2002 / gist:e319280ebc16de3c5d404b6250afd12e
Last active October 1, 2016 11:02
Org version switching
(setq org-paths '("~/.emacs.d/user-lisp/org-8.2.10/lisp" "~/.emacs.d/user-lisp/org-8.2.10/contrib/lisp"
"~/.emacs.d/user-lisp/org-mode/lisp"
"~/.emacs.d/user-lisp/org-mode/contrib/lisp"
"c:/Users/User/.emacs.d/elpa/org-20150511/"))
(defun org-clear-path ()
(interactive)
(setq load-path (delete-if (lambda (p) (member p org-paths)) load-path)))
(defun org-version-switch (org-path)
libbwinpthread-*.dll ; msys2 built emacs does not work without it?
;; Image support
libpng*.dll - png images
libtiff-*.dll - tiff images
libtiffxx-*.dll - tiff images
libjpeg-*.dll - jpeg images
libgif-*.dll - gif images
librsvg-*.dll - svg images
libXpm-noX*.dll - xpm images
;; Gnutls requirements
@sg2002
sg2002 / .emacs.desktop
Created July 2, 2016 13:34
Desktop.el bug
;; -*- mode: emacs-lisp; coding: emacs-mule; -*-
;; --------------------------------------------------------------------------
;; Desktop File for Emacs
;; --------------------------------------------------------------------------
;; Created Sat Jul 2 16:31:54 2016
;; Desktop file format version 208
;; Emacs version 25.0.95.1
;; Global section:
(setq desktop-saved-frameset [frameset 1 (22391 49738 40627 600000) (desktop . "208") "User@USER-HP" nil nil ((((font-backend uniscribe gdi) (font . "-outline-Courier New-normal-normal-normal-mono-13-*-*-*-c-*-iso8859-1") (border-width . 2) (internal-border-width . 0) (right-divider-width . 0) (bottom-divider-width . 0) (vertical-scroll-bars . right) (horizontal-scroll-bars . t) (foreground-color . "SystemWindowText") (background-color . "SystemWindow") (mouse-color . "black") (border-color . "black") (screen-gamma) (line-spacing) (left-fringe . 8) (right-fringe . 8) (alpha) (menu-bar-lines . 1) (tool-bar-lines . 3) (height . 36) (title) (icon-type) (auto-raise) (aut
@sg2002
sg2002 / init.el
Created July 2, 2016 00:43
Desktop.el bug
;; Added by Package.el. This must come before configurations of
;; installed packages. Don't delete this line. If you don't want it,
;; just comment it out by adding a semicolon to the start of the line.
;; You may delete these explanatory comments.
(package-initialize)
(desktop-save-mode 1)
(setq desktop-save t
desktop-dirname user-emacs-directory
(require 'erc-services)
(setq erc-autojoin-timing 'ident)
(defun erc-ghost-maybe (server nick)
"Send GHOST message to NickServ if NICK ends with `erc-nick-uniquifier'.
The function is suitable for `erc-after-connect'."
(when (string-match (format "\\(.*?\\)%s+$" erc-nick-uniquifier) nick)
(let ((nick-orig (match-string 1 nick))
(password erc-session-password))
(erc-message "PRIVMSG" (format "NickServ GHOST %s %s"