Skip to content

Instantly share code, notes, and snippets.

View sabof's full-sized avatar

Evgkeni Sampelnikof sabof

  • London, United Kingdom
View GitHub Profile
@sabof
sabof / gist:4483784
Last active December 10, 2015 19:48
The code that generates the es-lib markdown documentation. Copy-pasted as it was - might need some tweaking to make it work for you
(defun* buffer-defuns (&optional (buffer (current-buffer)))
(with-current-buffer buffer
(save-excursion
(goto-char (point-min))
(let (names)
(while (re-search-forward "^(defun[*]? \\(\\_<.+?\\_>\\)" nil t)
(push (intern (match-string-no-properties 1)) names))
names))))
(defun* buffer-macros (&optional (buffer (current-buffer)))
@sabof
sabof / javascript-imenu.el
Last active December 13, 2015 16:39
javascript function lookup
(defun es-js-imenu-create-index ()
"Return an imenu index for the current buffer."
(save-excursion
(save-restriction
(let (unique-names result name pos)
(widen)
(goto-char (point-min))
(while (re-search-forward
(concat "\\(\\_<.+?\\_>\\) = function"
"\\|"
@sabof
sabof / es-kill-buffer.el
Created March 21, 2013 20:18
What I use to kill buffers
(require 'cl)
(defun es-kill-buffer-this-window ()
(interactive)
(let* (( was-dedicated (window-dedicated-p))
( buf (current-buffer))
( kill-result
(if (or (get-buffer-process buf) (buffer-modified-p buf))
(when (kill-buffer)
(when (and was-dedicated
(require 'emms-setup)
(require 'emms-queue)
(require 'emms-playlist-mode)
(require 'emms-playlist-sort)
(require 'server)
(require 'emms-cover)
(require 'emms-history)
(require 'emms-mark)
(require 'emms-mobile-remote)
(ignore-errors ; Causes a stupid error
@sabof
sabof / es-patch.el
Last active December 15, 2015 15:39
es-patch
(defun es-patch (&optional patch-string custom-args)
(interactive
(list nil
current-prefix-arg
))
(let (( patch-temp-file
(make-temp-file "patch"))
default-command
( \default-args
(concat "--no-backup-if-mismatch"
(defun wc/narrow-window ()
(let (( new-right
(max 0 (+ (or (cdr (window-margins)) 0)
(- (window-body-width) fill-column)))))
(set-window-margins nil (car (window-margins)) new-right)
(set-window-fringes nil (car (window-fringes)) 2)))
(define-minor-mode wrap-column-mode
"Wrap the text at `fill-column'.
Works by adjusting the right margin."
@sabof
sabof / gist:6201962
Last active December 20, 2015 21:59
es-scrape-web-listing
;; -*- lexical-binding: t -*-
(require 'cl-lib)
(defun es-scrape-web-listing
(start-url collect-function next-url-function done-function
&optional pages-limit silent)
"Retrieve a list of things from a multi-page web document.
START-URL is the location from which to start scraping.
@sabof
sabof / gist:6329267
Last active December 21, 2015 15:49
Customizing flymake output
(defadvice flymake-post-syntax-check (before coffee-no-spaces activate)
"Warn about space indentation when in coffee-mode."
(when (eq major-mode 'coffee-mode)
(let (bad-spaces)
(save-excursion
(goto-char (point-min))
(while (re-search-forward
"^[[:blank:]]*\\(?1: \\)[[:blank:]]*[^[:blank:]\n]"
nil t)
(let (( ppss (syntax-ppss (match-beginning 1))))
@sabof
sabof / gist:6474059
Last active December 22, 2015 12:39
Replace the parser in newsticker
(defun es-xml-process-keywords (keywords)
(mapcar
(lambda (pair)
(let ( (keyword-name (car pair)))
(cons
(cond ( (stringp keyword-name)
(intern keyword-name))
( (consp keyword-name)
(intern (cdr keyword-name)))
( t keyword-name))
@sabof
sabof / gist:7363048
Created November 7, 2013 22:35
es-make-minibuffer-frame
(defun es-make-minibuffer-frame ()
(interactive)
(let* (( last-recursion-depth )
( frame (make-frame '((width . 60)
(height . 4)
(minibuffer . only)
(title . "Emacs-Minibuffer"))))
( enable-recursive-minibuffers t)
;; Runs when going down a level, or when entering a prompt. Not ideal
( minibuffer-exit-hook (list (lambda ()