aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlenn Morris2010-10-06 19:37:39 -0700
committerGlenn Morris2010-10-06 19:37:39 -0700
commit7b9235ad958da061a3dc412c52ec28326d1a836d (patch)
treea5467d6b1eb3bd86fea0ea1373daf5475f8e23f7
parent52da218259dcd25143ae5bc6fcd79b898ad15fab (diff)
downloademacs-7b9235ad958da061a3dc412c52ec28326d1a836d.tar.gz
emacs-7b9235ad958da061a3dc412c52ec28326d1a836d.zip
Add a shadow-mode for load-path shadows.
* lisp/emacs-lisp/shadow.el (shadow-font-lock-keywords): New variable. (shadow-mode): New mode. (shadow-find-file): New button. (list-load-path-shadows): Use shadow-mode and buttons.
-rw-r--r--lisp/ChangeLog5
-rw-r--r--lisp/emacs-lisp/shadow.el49
2 files changed, 46 insertions, 8 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 1c01b1c64ed..34e9282d4c6 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,5 +1,10 @@
12010-10-07 Glenn Morris <rgm@gnu.org> 12010-10-07 Glenn Morris <rgm@gnu.org>
2 2
3 * emacs-lisp/shadow.el (shadow-font-lock-keywords): New variable.
4 (shadow-mode): New mode.
5 (shadow-find-file): New button.
6 (list-load-path-shadows): Use shadow-mode and buttons.
7
3 * iimage.el (iimage-version): Remove. 8 * iimage.el (iimage-version): Remove.
4 (iimage-mode-image-search-path, iimage-mode-image-regex-alist): 9 (iimage-mode-image-search-path, iimage-mode-image-regex-alist):
5 Turn into defcustoms. 10 Turn into defcustoms.
diff --git a/lisp/emacs-lisp/shadow.el b/lisp/emacs-lisp/shadow.el
index a41db864a1b..630aadba1d4 100644
--- a/lisp/emacs-lisp/shadow.el
+++ b/lisp/emacs-lisp/shadow.el
@@ -151,6 +151,34 @@ See the documentation for `list-load-path-shadows' for further information."
151 (and (= (nth 7 (file-attributes f1)) 151 (and (= (nth 7 (file-attributes f1))
152 (nth 7 (file-attributes f2))) 152 (nth 7 (file-attributes f2)))
153 (eq 0 (call-process "cmp" nil nil nil "-s" f1 f2)))))))) 153 (eq 0 (call-process "cmp" nil nil nil "-s" f1 f2))))))))
154
155(defvar shadow-font-lock-keywords
156 `((,(format "hides \\(%s.*\\)"
157 (file-name-directory (locate-library "simple.el")))
158 . (1 font-lock-warning-face)))
159 "Keywords to highlight in `shadow-mode'.")
160
161(define-derived-mode shadow-mode fundamental-mode "Shadow"
162 "Major mode for load-path shadows buffer."
163 (set (make-local-variable 'font-lock-defaults)
164 '((shadow-font-lock-keywords)))
165 (setq buffer-undo-list t
166 buffer-read-only t))
167
168;; TODO use text-properties instead, a la dired.
169(require 'button)
170(define-button-type 'shadow-find-file
171 'follow-link t
172;; 'face 'default
173 'action (lambda (button)
174 (let ((file (concat (button-get button 'shadow-file) ".el")))
175 (or (file-exists-p file)
176 (setq file (concat file ".gz")))
177 (if (file-readable-p file)
178 (pop-to-buffer (find-file-noselect file))
179 (error "Cannot read file"))))
180 'help-echo "mouse-2, RET: find this file")
181
154 182
155;;;###autoload 183;;;###autoload
156(defun list-load-path-shadows (&optional stringp) 184(defun list-load-path-shadows (&optional stringp)
@@ -234,14 +262,20 @@ function, `find-emacs-lisp-shadows'."
234 ;; Create the *Shadows* buffer and display shadowings there. 262 ;; Create the *Shadows* buffer and display shadowings there.
235 (let ((string (buffer-string))) 263 (let ((string (buffer-string)))
236 (with-current-buffer (get-buffer-create "*Shadows*") 264 (with-current-buffer (get-buffer-create "*Shadows*")
237 (fundamental-mode) ;run after-change-major-mode-hook.
238 (display-buffer (current-buffer)) 265 (display-buffer (current-buffer))
239 (setq buffer-undo-list t 266 (shadow-mode) ; run after-change-major-mode-hook
240 buffer-read-only nil) 267 (let ((inhibit-read-only t))
241 (erase-buffer) 268 (erase-buffer)
242 (insert string) 269 (insert string)
243 (insert msg "\n") 270 (insert msg "\n")
244 (setq buffer-read-only t))) 271 (while (re-search-backward "\\(^.*\\) hides \\(.*$\\)"
272 nil t)
273 (dotimes (i 2)
274 (make-button (match-beginning (1+ i))
275 (match-end (1+ i))
276 'type 'shadow-find-file 'shadow-file
277 (match-string (1+ i)))))
278 (goto-char (point-max)))))
245 ;; We are non-interactive, print shadows via message. 279 ;; We are non-interactive, print shadows via message.
246 (unless (zerop n) 280 (unless (zerop n)
247 (message "This site has duplicate Lisp libraries with the same name. 281 (message "This site has duplicate Lisp libraries with the same name.
@@ -259,5 +293,4 @@ version unless you know what you are doing.\n")
259 293
260(provide 'shadow) 294(provide 'shadow)
261 295
262;; arch-tag: 0480e8a7-62ed-4a12-a9f6-f44ded9b0830
263;;; shadow.el ends here 296;;; shadow.el ends here