Remove project & _list_projects, I don't use them anymore.
2 (defun kill-whole-line ()
4 (move-beginning-of-line 1)
8 (defun jao-toggle-selective-display (column)
10 (set-selective-display
11 (if selective-display nil (or column 1))))
15 (defun diff-buffer-with-associated-file ()
16 "View the differences between BUFFER and its associated file.
17 This requires the external program \"diff\" to be in your `exec-path'.
18 Returns nil if no differences found, 't otherwise."
20 (let ((buf-filename buffer-file-name)
21 (buffer (current-buffer)))
23 (error "Buffer %s has no associated file" buffer))
24 (let ((diff-buf (get-buffer-create
25 (concat "*Assoc file diff: "
28 (with-current-buffer diff-buf
29 (setq buffer-read-only nil)
31 (let ((tempfile (make-temp-file "buffer-to-file-diff-")))
34 (with-current-buffer buffer
35 (write-region (point-min) (point-max) tempfile nil 'nomessage))
37 (apply #'call-process "diff" nil diff-buf nil
39 (when (and (boundp 'ediff-custom-diff-options)
40 (stringp ediff-custom-diff-options))
41 (list ediff-custom-diff-options))
42 (list buf-filename tempfile))))
44 (message "No differences found")
47 (with-current-buffer diff-buf
48 (goto-char (point-min))
49 (if (fboundp 'diff-mode)
52 (display-buffer diff-buf)
54 (when (file-exists-p tempfile)
55 (delete-file tempfile)))))))
57 ;; tidy up diffs when closing the file
58 (defun kill-associated-diff-buf ()
59 (let ((buf (get-buffer (concat "*Assoc file diff: "
65 (add-hook 'kill-buffer-hook 'kill-associated-diff-buf)
67 (defun de-context-kill (arg)
68 "Kill buffer, taking gnuclient into account."
70 (when (and (buffer-modified-p)
72 (not (string-match "\\*.*\\*" (buffer-name)))
73 ;; erc buffers will be automatically saved
74 (not (eq major-mode 'erc-mode))
76 (let ((differences 't))
77 (when (file-exists-p buffer-file-name)
78 (setq differences (diff-buffer-with-associated-file)))
79 (error (if differences
80 "Buffer has unsaved changes"
81 "Buffer has unsaved changes, but no differences wrt. the file"))))
82 (if (and (boundp 'gnuserv-minor-mode)
85 (set-buffer-modified-p nil)
86 (kill-buffer (current-buffer))))
90 (lambda (&optional arg) "Keyboard macro." (interactive "p") (kmacro-exec-ring-item (quote ("\\left(" 0 "%d")) arg)))
92 (lambda (&optional arg) "Keyboard macro." (interactive "p") (kmacro-exec-ring-item (quote ("\\right)" 0 "%d")) arg)))
94 (defun my-list-buffers (&optional files-only)
95 "Opens list-buffers and put focus on it"
97 (let ((b (list-buffers-noselect files-only)))
100 (delete-other-windows)))
103 (defun jao-toggle-selective-display (column)
105 (set-selective-display
106 (if selective-display nil (or column 1))))
108 (defun really-revert-buffer ()
109 "Revert the buffer without asking for confirmation."
111 (revert-buffer t t t))
113 (defun close-project (project)
114 "Filesets never seems to work."
116 (dolist (buffer (buffer-list))
117 (with-current-buffer buffer
118 (if (and (buffer-file-name)
119 (string-match project (buffer-file-name)))
120 (kill-buffer buffer)))))
122 (defun my-clean-line (foo)
124 (indent-for-tab-command)
125 (move-end-of-line nil)
126 (delete-horizontal-space)
129 (defun insert-time-stamp ()
131 (insert-and-inherit (time-stamp-yyyy/mm/dd) " - "(time-stamp-hh:mm:ss))
134 (provide 'ag-functions)