(defun backward-delete-word (N) "Delete previous N words." (interactive "*p")(delete-word (- N))) (defun delete-word (N) "Delete following N words." (interactive "*p") (delete-region (point)(save-excursion (forward-word N)(point)))) (defun kill-line-or-region () "Kill region if selected, otherwise kill line." (interactive) (if (and mark-active transient-mark-mode)(kill-region (point)(mark))(kill-line))) (defun pull-line-down (N) "Pull line down N times." (interactive "*p") (let ((col (current-column)))(kill-whole-line 1)(forward-line N)(yank 1)(pop kill-ring)(forward-line -1) (move-to-column col))) (defun pull-line-up (N) "Pull line up N times." (interactive "*p") (let ((col (current-column)))(kill-whole-line 1)(forward-line (- N))(yank 1)(pop kill-ring)(forward-line -1) (move-to-column col))) (defun zap-back-to-char (char) "Delete region back to, but not including, CHAR." (interactive "cZap back to char: ") (let ((case-fold-search nil)) (delete-region (point)(progn (search-backward (char-to-string char))(forward-char)(point))))) (defun zap-up-to-char (char) "Delete region up to, but not including, CHAR." (interactive "cZap to char: ") (let ((case-fold-search nil)) (delete-region (point)(progn (search-forward (char-to-string char))(backward-char)(point))))) (defun delete-all-blank-lines () "Delete all blank lines in buffer." (interactive) (save-excursion (goto-char (point-min)) (let ((count 0))(while (search-forward "\n\n" nil t)(goto-char (point-min)) (while (search-forward "\n\n" nil t)(replace-match "\n")(setq count (+ count 1))) (goto-char (point-min))) (if (= (following-char) 10)(progn (delete-char 1)(setq count (+ count 1)))) (message "Deleted %d blank lines" count)))) (defun delete-indentation-nospace () "Join this line to previous with no whitespace at join." (interactive) (delete-indentation)(delete-horizontal-space)) (defun downcase-word-or-region (N) "Downcase N words or region." (interactive "*p") (if (and mark-active transient-mark-mode)(downcase-region (point)(mark))(downcase-word N))) (defun upcase-word-or-region (N) "Upcase N words or region." (interactive "*p") (if (and mark-active transient-mark-mode)(upcase-region (point)(mark))(upcase-word N)))