Skip to content

Instantly share code, notes, and snippets.

@anildigital
Created November 23, 2008 09:50
Show Gist options
  • Save anildigital/28082 to your computer and use it in GitHub Desktop.
Save anildigital/28082 to your computer and use it in GitHub Desktop.
(defun anil-find-config ()
(interactive)
(let ((config-file
(ido-completing-read "Config file: " (reject (directory-files "~/.emacs.d/anil/")
(lambda (x) (string-match "^\\." x))))))
(if (empty? config-file)
(find-file "~/.emacs.d/anil.el")
(find-file (concat "~/.emacs.d/anil/" config-file)))))
;; fix kill-word
(defun anil-kill-word (arg)
"Special version of kill-word which swallows spaces separate from words"
(interactive "p")
(let ((whitespace-regexp "\\s-+"))
(kill-region (point)
(cond
((looking-at whitespace-regexp) (re-search-forward whitespace-regexp) (point))
((looking-at "\n") (kill-line) (anil-kill-word arg))
(t (forward-word arg) (point))))))
(defun anil-backward-kill-word (arg)
"Special version of backward-kill-word which swallows spaces separate from words"
(interactive "p")
(if (looking-back "\\s-+")
(kill-region (point) (progn (re-search-backward "\\S-") (forward-char 1) (point)))
(backward-kill-word arg)))
(require 'thingatpt)
(defun anil-change-num-at-point (fn)
(let* ((num (string-to-number (thing-at-point 'word)))
(bounds (bounds-of-thing-at-point 'word)))
(save-excursion
(goto-char (car bounds))
(anil-kill-word 1)
(insert (number-to-string (funcall fn num 1))))))
; duplicate the current line
(defun anil-duplicate-line ()
(interactive)
(beginning-of-line)
(copy-region-as-kill (point) (progn (end-of-line) (point)))
(anil-insert-blank-line-after-current)
(yank)
(beginning-of-line))
(defun anil-inc-num-at-point ()
(interactive)
(anil-change-num-at-point '+))
(defun anil-dec-num-at-point ()
(interactive)
(anil-change-num-at-point '-))
(defun anil-insert-blank-line-after-current ()
(interactive)
(end-of-line)
(newline-and-indent))
(defun gist-buffer-confirm ()
(interactive)
(when (yes-or-no-p "Are you sure you want to Gist this buffer? ") (gist-buffer)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment