Guest User

Untitled

a guest
Feb 21st, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.02 KB | None | 0 0
  1. (defun anil-find-config ()
  2. (interactive)
  3. (let ((config-file
  4. (ido-completing-read "Config file: " (reject (directory-files "~/.emacs.d/anil/")
  5. (lambda (x) (string-match "^\\." x))))))
  6. (if (empty? config-file)
  7. (find-file "~/.emacs.d/anil.el")
  8. (find-file (concat "~/.emacs.d/anil/" config-file)))))
  9.  
  10. ;; fix kill-word
  11. (defun anil-kill-word (arg)
  12. "Special version of kill-word which swallows spaces separate from words"
  13. (interactive "p")
  14.  
  15. (let ((whitespace-regexp "\\s-+"))
  16. (kill-region (point)
  17. (cond
  18. ((looking-at whitespace-regexp) (re-search-forward whitespace-regexp) (point))
  19. ((looking-at "\n") (kill-line) (anil-kill-word arg))
  20. (t (forward-word arg) (point))))))
  21.  
  22. (defun anil-backward-kill-word (arg)
  23. "Special version of backward-kill-word which swallows spaces separate from words"
  24. (interactive "p")
  25. (if (looking-back "\\s-+")
  26. (kill-region (point) (progn (re-search-backward "\\S-") (forward-char 1) (point)))
  27. (backward-kill-word arg)))
  28.  
  29.  
  30. (require 'thingatpt)
  31. (defun anil-change-num-at-point (fn)
  32. (let* ((num (string-to-number (thing-at-point 'word)))
  33. (bounds (bounds-of-thing-at-point 'word)))
  34. (save-excursion
  35. (goto-char (car bounds))
  36. (anil-kill-word 1)
  37. (insert (number-to-string (funcall fn num 1))))))
  38.  
  39. ; duplicate the current line
  40. (defun anil-duplicate-line ()
  41. (interactive)
  42. (beginning-of-line)
  43. (copy-region-as-kill (point) (progn (end-of-line) (point)))
  44. (anil-insert-blank-line-after-current)
  45. (yank)
  46. (beginning-of-line))
  47.  
  48.  
  49. (defun anil-inc-num-at-point ()
  50. (interactive)
  51. (anil-change-num-at-point '+))
  52.  
  53. (defun anil-dec-num-at-point ()
  54. (interactive)
  55. (anil-change-num-at-point '-))
  56.  
  57.  
  58. (defun anil-insert-blank-line-after-current ()
  59. (interactive)
  60. (end-of-line)
  61. (newline-and-indent))
  62.  
  63.  
  64.  
  65. (defun gist-buffer-confirm ()
  66. (interactive)
  67. (when (yes-or-no-p "Are you sure you want to Gist this buffer? ") (gist-buffer)))
Add Comment
Please, Sign In to add comment