Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Feb 19th, 2013  |  syntax: Lisp  |  size: 0.75 KB  |  views: 26  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
This paste has a previous version, view the difference. Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. (defun delete-blank-lines-or-char ()
  2.   (interactive)
  3.   (cond
  4.    ((region-active-p) (delete-region (region-beginning) (region-end)))
  5.    ((looking-at "\n\n") (delete-blank-lines))
  6.    ((looking-at "\\s-*\n[\\s-]*") (just-one-space) (delete-char 1) (just-one-space))
  7.    ((looking-at "  ") (just-one-space))
  8.    (t (delete-char 1)))
  9.   )
  10.  
  11. (global-set-key [delete] 'delete-blank-lines-or-char)
  12.  
  13. (defadvice delete-blank-lines-or-char (around smart-delete-parenthesis activate)
  14.   (cond
  15.    ((looking-at ")")
  16.     (save-excursion
  17.       (forward-char 1)
  18.       (backward-list 1)
  19.       (delete-char 1))
  20.     (delete-char 1))
  21.    ((looking-at "(")
  22.     (save-excursion
  23.       (forward-list 1)
  24.       (delete-char -1))
  25.     (delete-char 1))
  26.    (t ad-do-it))
  27.   )
clone this paste RAW Paste Data