Skip to content

Instantly share code, notes, and snippets.

(defmacro fmt (str)
"Elisp string interpolation.
Example:
(fmt \"My name is #{user-full-name}, I am running Emacs #{(if (display-graphic-p) \\\"with a GUI\\\" \\\"in a terminal\\\".)}\""
(let ((exprs nil))
(with-temp-buffer
(insert str)
(goto-char 1)
(defmacro create-scratch-buffer (name &optional comment body)
"Create a new custom scratch buffer. The name should be a valid major mode name without -mode suffix.
The body should be lambda block or a symbol of function that be invoked after a scratch buffer created. nil is accepted to turn it off."
`(defun ,(intern (concat "scratch-" name))
()
(interactive)
(let ((bufname (concat "*scratch-" ,name "*")))
(if (buffer-live-p (get-buffer bufname))
(switch-to-buffer bufname)
(with-current-buffer (get-buffer-create bufname)
;; This macro creates new compilation commands
(defmacro ff/add-compilation-command (name &optional key)
(let ((buffer-name (concat "*" name "*"))
(compile-symbol (intern name))
(recompile-symbol (intern (concat "re" name))))
(when (fboundp compile-symbol)
(warn "redefining command `%s'" name))
(when (fboundp recompile-symbol)
(warn "redefining command `re%s'" name))
`(progn
;;; how to use
;; (add-hook 'html-mode-hook 'django-kyr-tag-mode)
;;(util-macro-install "dkt:")
;;; how to use
;; (add-hook 'html-mode-hook 'django-kyr-tag-mode)
;;(util-macro-install "dkt:")
(eval-when-compile (require 'cl))
@caiorss
caiorss / dbg.el
Last active August 29, 2015 14:24 — forked from pervognsen/dbg.el
(require 'cl)
(require 'peg)
(defcustom dbg-mi-process-name "dbg-mi" "")
(defcustom dbg-mi-buffer-name "*dbg-mi*" "")
(defvar dbg-mi-process nil)
(defvar dbg-mi-buffer nil)
@caiorss
caiorss / macros.el
Last active September 14, 2022 00:18
Emacs Lisp/Elisp Macro Examples
;; Elisp session in REPL IELM
;;
;;
;;
ELISP> (defmacro inc (var)
(list 'setq var (list '1+ var)))
inc
ELISP> (setq x 0)
0 (#o0, #x0, ?\C-@)
@caiorss
caiorss / programming_language_selection.txt
Created July 12, 2015 06:25
Programming Language Selection Guidelines
* IDE Support
* Community Size
* Documentation, Documentation Generators
* FFI (Foreign Function Interface) for C/C++
* Libraries
* GUI Toolkits
* Multicore and Multitask
* Available Manpower
@caiorss
caiorss / jdk_download.sh
Last active September 16, 2015 20:03 — forked from P7h/jdk_download.sh
Commands / shell script to download JDK / JRE / Java binaries from Oracle website from terminal / shell / command line / command prompt.
##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### #####
### Shell script to download Oracle JDK / JRE / Java binaries from Oracle website using terminal / command / shell prompt using wget.
### You can download all the binaries one-shot by just giving the BASE_URL.
### Script might be useful if you need Oracle JDK on Amazon EC2 env.
### Script is updated for every JDK release.
### Features:-
# 1. Resumes a broken / interrupted [previous] download, if any.
# 2. Renames the file to a proper name with including platform info.
@caiorss
caiorss / .ghci
Created March 1, 2016 18:55 — forked from pyrtsa/.ghci
.ghci — Essential parts of my Haskell REPL config.
-- Show loaded modules in window title and use a green "λ>" as prompt.
-- Subsequent lines of multi-line commands shall begin with " |".
:set prompt "\SOH\ESC]0;GHCi: %s\BEL\ESC[32;1m\STXλ>\SOH\ESC[0m\STX "
:set prompt2 "\SOH\ESC[32;1m\STX |\SOH\ESC[0m\STX "
-- Paste and evaluate text from the OS X clipboard. (The pasted text also
-- prints in yellow unless pasting quietly using :paste-quiet.)
:set -package process
:def paste \_ -> do { paste <- System.Process.readProcess "pbpaste" [] ""; let cmd = if '\n' `elem` paste then ":{\ntype Ö = ()\n" ++ paste ++ "\n:}" else paste in putStrLn ("\SOH\ESC[33m\STX" ++ paste ++ "\SOH\ESC[0m\STX") >> return (":cmd return " ++ show cmd) }
:def paste-quiet \_ -> do { paste <- System.Process.readProcess "pbpaste" [] ""; let cmd = if '\n' `elem` paste then ":{\ntype Ö = ()\n" ++ paste ++ "\n:}" else paste in return (":cmd return " ++ show cmd) }
@caiorss
caiorss / helm_config.el
Created October 1, 2016 23:39 — forked from izahn/helm_config.el
Helm config
;;; Completion hints for files and buffers buffers
(require 'helm-config)
(helm-mode 1)
;;rebind tab to do persistent action
(define-key helm-map (kbd "<tab>") 'helm-execute-persistent-action)
;; make TAB works in terminal
(define-key helm-map (kbd "C-i") 'helm-execute-persistent-action)
;list actions using C-z
(define-key helm-map (kbd "C-z") 'helm-select-action)