;; TODO: unused?
(defun kill-whole-line ()
;; TODO: annoying, get rid of it.
(defun diff-buffer-with-associated-file ()
"View the differences between BUFFER and its associated file.
This requires the external program \"diff\" to be in your `exec-path'.
Returns nil if no differences found, 't otherwise."
(let ((buf-filename buffer-file-name)
(error "Buffer %s has no associated file" buffer))
(let ((diff-buf (get-buffer-create
(concat "*Assoc file diff: "
(setq buffer-read-only nil)
(let ((tempfile (make-temp-file "buffer-to-file-diff-")))
(write-region (point-min) (point-max) tempfile nil 'nomessage))
(apply #'call-process "diff" nil diff-buf nil
(when (and (boundp 'ediff-custom-diff-options)
(list buf-filename tempfile))))
(message "No differences found")
(if (fboundp 'diff-mode)
(when (file-exists-p tempfile)
;; tidy up diffs when closing the file
(defun kill-associated-diff-buf ()
(let ((buf (get-buffer (concat "*Assoc file diff: "
(when (bufferp buf)
(add-hook 'kill-buffer-hook 'kill-associated-diff-buf)
(defun de-context-kill (arg)
"Kill buffer, taking gnuclient into account."
(when (and (buffer-modified-p)
(not (string-match "\\*.*\\*" (buffer-name)))
;; erc buffers will be automatically saved
(not (eq major-mode 'erc-mode))
(= 1 arg))
(let ((differences 't))
(when (file-exists-p buffer-file-name)
(setq differences (diff-buffer-with-associated-file)))
(error (if differences
"Buffer has unsaved changes"
"Buffer has unsaved changes, but no differences wrt. the file"))))
(if (and (boundp 'gnuserv-minor-mode)
(lambda (&optional arg) "Keyboard macro." (interactive "p") (kmacro-exec-ring-item (quote ("\\left(" 0 "%d")) arg)))
(lambda (&optional arg) "Keyboard macro." (interactive "p") (kmacro-exec-ring-item (quote ("\\right)" 0 "%d")) arg)))
(defun my-list-buffers (&optional files-only)
"Opens list-buffers and put focus on it"
(let ((b (list-buffers-noselect files-only)))
(defun really-revert-buffer ()
"Revert the buffer without asking for confirmation."
(revert-buffer t t t))
(defun close-project (project)
"Filesets never seems to work."
(dolist (buffer (buffer-list))
(if (and (buffer-file-name)
(string-match project (buffer-file-name)))
(defun my-clean-line (foo)
(defun insert-time-stamp ()
(insert-and-inherit (time-stamp-yyyy/mm/dd) " - "(time-stamp-hh:mm:ss))