From 65f017fdd10482598fe8ff874f44a50bfdcde05f Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Wed, 20 Apr 2011 13:40:17 -0300 Subject: [PATCH] * packages/all-1.0.el: Change version. Address byte-compiler warnings. Rename the `marker' property to `all-marker'. (all-mode-map): Move initialization into declaration. (all-buffer): Mark buffer-local. (all-mode): Use define-derived-mode. Setup the change-functions buffer-locally. (all): Use read-string. Let-bind all-initialization-p. (all-insert): Use a `match' face text property rather then a `highlight' face overlay for the match highlight. * admin/archive-contents.el (batch-make-archive-contents): Don't burp if a commentary section is missing. * .bzrignore: Ignore .elc files. * packages/load-dir-0.0.2.el: Update Commentary from load-dir-readme.txt. --- .bzrignore | 1 + ChangeLog | 17 +++ admin/archive-contents.el | 5 +- packages/{all-19970304.el => all-1.0.el} | 127 ++++++++++------------- packages/all-readme.txt | 10 +- packages/archive-contents | 4 +- packages/load-dir-0.0.2.el | 28 +++-- 7 files changed, 91 insertions(+), 101 deletions(-) create mode 100644 .bzrignore rename packages/{all-19970304.el => all-1.0.el} (65%) diff --git a/.bzrignore b/.bzrignore new file mode 100644 index 000000000..c531d9867 --- /dev/null +++ b/.bzrignore @@ -0,0 +1 @@ +*.elc diff --git a/ChangeLog b/ChangeLog index ce5bde290..758ba04e3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,20 @@ +2011-04-20 Stefan Monnier + + * packages/all-1.0.el: Change version. Address byte-compiler warnings. + Rename the `marker' property to `all-marker'. + (all-mode-map): Move initialization into declaration. + (all-buffer): Mark buffer-local. + (all-mode): Use define-derived-mode. Setup the change-functions + buffer-locally. + (all): Use read-string. Let-bind all-initialization-p. + (all-insert): Use a `match' face text property rather then + a `highlight' face overlay for the match highlight. + * admin/archive-contents.el (batch-make-archive-contents): Don't burp + if a commentary section is missing. + * .bzrignore: Ignore .elc files. + * packages/load-dir-0.0.2.el: Update Commentary from + load-dir-readme.txt. + 2011-04-20 Per Abrahamsen * packages/all-19970304.el: New package. diff --git a/admin/archive-contents.el b/admin/archive-contents.el index 75c75e7f3..5254fbe24 100644 --- a/admin/archive-contents.el +++ b/admin/archive-contents.el @@ -71,7 +71,10 @@ (concat pkg "-readme.txt")) (erase-buffer) (emacs-lisp-mode) - (insert commentary) + (insert (or commentary + (prog1 "No description" + (message "Missing Commentary in %s" + file)))) (goto-char (point-min)) (while (looking-at ";*[ \t]*\\(commentary[: \t]*\\)?\n") (delete-region (match-beginning 0) diff --git a/packages/all-19970304.el b/packages/all-1.0.el similarity index 65% rename from packages/all-19970304.el rename to packages/all-1.0.el index e5ddf14b9..0d2fe2278 100644 --- a/packages/all-19970304.el +++ b/packages/all-1.0.el @@ -1,10 +1,10 @@ -;;; all.el --- Edit all lines matching a given regexp. +;;; all.el --- Edit all lines matching a given regexp -;; Copyright (C) 1985, 1986, 1987, 1992, 1994, 2011 Free Software Foundation, Inc. +;; Copyright (C) 1985-1987, 1992, 1994, 2011 Free Software Foundation, Inc. ;; Copyright (C) 1994 Per Abrahamsen ;; Author: Per Abrahamsen -;; Version: $Id: all.el,v 5.2 1997/03/04 10:29:42 abraham Exp $ +;; Version: 1.0 ;; Keywords: matching ;; LCD Archive Entry: @@ -28,13 +28,11 @@ ;;; Commentary: -;; Just like occur, except that changes in the *All* buffer is +;; Just like occur, except that changes in the *All* buffer are ;; propagated to the original buffer. -;; I also added highlighting of the matches. - ;; You can no longer use mouse-2 to find a match in the original file, -;; since the default definition of mouse to is useful. +;; since the default definition of mouse too is useful. ;; However, `C-c C-c' still works. ;; Line numbers are not listed in the *All* buffer. @@ -44,47 +42,40 @@ ;; Some limitations: ;; - Undo in the *All* buffer is an ordinary change in the original. -;; - Changes to the original buffer is not reflected in the *All* buffer. +;; - Changes to the original buffer are not reflected in the *All* buffer. ;; - A single change in the *All* buffer must be limited to a single match. -;; Requires GNU Emacs 19.23 or later. - ;;; Code: -(defvar all-mode-map ()) - -(if all-mode-map - () - (setq all-mode-map (make-sparse-keymap)) - (define-key all-mode-map "\C-c\C-c" 'all-mode-goto)) +(defvar all-mode-map + (let ((map (make-sparse-keymap))) + (define-key map "\C-c\C-c" 'all-mode-goto) + map)) (defvar all-buffer nil) +(make-variable-buffer-local 'all-buffer) -(defun all-mode () +(define-derived-mode all-mode fundamental-mode "All" "Major mode for output from \\[all]. All changes made in this buffer will be propagated to the buffer where you ran \\[all]. Press \\[all-mode-goto] to go to the same spot in the original buffer." - (kill-all-local-variables) - (use-local-map all-mode-map) - (setq major-mode 'all-mode) - (setq mode-name "All") - (make-local-variable 'all-buffer) - (run-hooks 'all-mode-hook)) + (add-hook 'before-change-functions 'all-before-change-function nil 'local) + (add-hook 'after-change-functions 'all-after-change-function nil 'local)) (defun all-mode-find (pos) ;; Find position in original buffer corresponding to POS. (let ((overlay (all-mode-find-overlay pos))) (if overlay - (+ (marker-position (overlay-get overlay 'marker)) + (+ (marker-position (overlay-get overlay 'all-marker)) (- pos (overlay-start overlay)))))) (defun all-mode-find-overlay (pos) ;; Find the overlay containing POS. (let ((overlays (overlays-at pos))) - (while (and overlays (null (overlay-get (car overlays) 'marker))) + (while (and overlays (null (overlay-get (car overlays) 'all-marker))) (setq overlays (cdr overlays))) (car-safe overlays))) @@ -100,7 +91,7 @@ Press \\[all-mode-goto] to go to the same spot in the original buffer." (defvar all-initialization-p nil) (defun all-before-change-function (from to) - ;; Check that change is legal + ;; Check that change is legal. (and all-buffer (not all-initialization-p) (let ((start (all-mode-find-overlay from)) @@ -108,8 +99,6 @@ Press \\[all-mode-goto] to go to the same spot in the original buffer." (not (and start (eq start end)))) (error "Changes should be limited to a single text piece"))) -(add-hook 'before-change-functions 'all-before-change-function) - (defun all-after-change-function (from to length) ;; Propagate changes from *All* buffer. (and all-buffer @@ -117,15 +106,11 @@ Press \\[all-mode-goto] to go to the same spot in the original buffer." (let ((buffer (current-buffer)) (pos (all-mode-find from))) (if pos - (progn - (set-buffer all-buffer) - (delete-region pos (+ pos length)) + (with-current-buffer all-buffer (save-excursion (goto-char pos) - (insert-buffer-substring buffer from to)) - (set-buffer buffer)))))) - -(add-hook 'after-change-functions 'all-after-change-function) + (delete-region pos (+ pos length)) + (insert-buffer-substring buffer from to))))))) ;;;###autoload (defun all (regexp &optional nlines) @@ -140,29 +125,24 @@ Interactively it is the prefix arg. The lines are shown in a buffer named `*All*'. Any changes made in that buffer will be propagated to this buffer." - (interactive (list (let* ((default (car regexp-history)) - (input - (read-from-minibuffer - (if default - (format - "Edit lines matching regexp (default `%s'): " default) - "Edit lines matching regexp: ") - nil nil nil - 'regexp-history))) - (if (> (length input) 0) input - (setcar regexp-history default))) - current-prefix-arg)) + (interactive + (list (let* ((default (car regexp-history))) + (read-string + (if default + (format + "Edit lines matching regexp (default `%s'): " default) + "Edit lines matching regexp: ") + nil 'regexp-history default)) + current-prefix-arg)) (setq nlines (if nlines (prefix-numeric-value nlines) list-matching-lines-default-context-lines)) - (setq all-initialization-p t) - (let ((first t) - (buffer (current-buffer)) + (let ((all-initialization-p t) + (buffer (current-buffer)) (prevend nil) (prevstart nil) (prevpos (point-min))) (with-output-to-temp-buffer "*All*" - (save-excursion - (set-buffer standard-output) + (with-current-buffer standard-output (all-mode) (setq all-buffer buffer) (insert "Lines matching ") @@ -172,7 +152,7 @@ Any changes made in that buffer will be propagated to this buffer." (if (eq buffer standard-output) (goto-char (point-max))) (save-excursion - (beginning-of-buffer) + (goto-char (point-min)) ;; Find next match, but give up if prev match was at end of buffer. (while (and (not (= prevpos (point-max))) (re-search-forward regexp nil t)) @@ -189,39 +169,36 @@ Any changes made in that buffer will be propagated to this buffer." (if (> nlines 0) (forward-line (1+ nlines)) (forward-line 1)) - (point))) - marker) + (point)))) (cond ((null prevend) (setq prevstart start prevend end)) ((> start prevend) - (all-insert) + (all-insert prevstart prevend regexp nlines) (setq prevstart start prevend end)) (t (setq prevend end))))) (if prevend - (all-insert))))) - (setq all-initialization-p nil)) + (all-insert prevstart prevend regexp nlines)))))) -(defun all-insert () +(defun all-insert (start end regexp nlines) ;; Insert match. - (save-excursion - (setq marker (make-marker)) - (set-marker marker prevstart) - (set-buffer standard-output) - (let ((from (point)) - to) - (insert-buffer-substring buffer prevstart prevend) - (setq to (point)) - (overlay-put (make-overlay from to) 'marker marker) - (goto-char from) - (while (re-search-forward regexp to t) - (overlay-put (make-overlay (match-beginning 0) (match-end 0)) - 'face 'highlight)) - (goto-char to) - (if (> nlines 0) - (insert "--------\n"))))) + (let ((marker (copy-marker start)) + (buffer (current-buffer))) + (with-current-buffer standard-output + (let ((from (point)) + to) + (insert-buffer-substring buffer start end) + (setq to (point)) + (overlay-put (make-overlay from to) 'all-marker marker) + (goto-char from) + (while (re-search-forward regexp to t) + (put-text-property (match-beginning 0) (match-end 0) + 'face 'match)) + (goto-char to) + (if (> nlines 0) + (insert "--------\n")))))) (provide 'all) diff --git a/packages/all-readme.txt b/packages/all-readme.txt index ebceec939..e09ec22b3 100644 --- a/packages/all-readme.txt +++ b/packages/all-readme.txt @@ -1,10 +1,8 @@ -Just like occur, except that changes in the *All* buffer is +Just like occur, except that changes in the *All* buffer are propagated to the original buffer. -I also added highlighting of the matches. - You can no longer use mouse-2 to find a match in the original file, -since the default definition of mouse to is useful. +since the default definition of mouse too is useful. However, `C-c C-c' still works. Line numbers are not listed in the *All* buffer. @@ -14,7 +12,5 @@ Ok, it is _not_ just like occur. Some limitations: - Undo in the *All* buffer is an ordinary change in the original. -- Changes to the original buffer is not reflected in the *All* buffer. +- Changes to the original buffer are not reflected in the *All* buffer. - A single change in the *All* buffer must be limited to a single match. - -Requires GNU Emacs 19.23 or later. diff --git a/packages/archive-contents b/packages/archive-contents index 7870263aa..7c0f77698 100644 --- a/packages/archive-contents +++ b/packages/archive-contents @@ -1,7 +1,7 @@ (1 (all . - [(19970304) - nil "Edit all lines matching a given regexp." single]) + [(1 0) + nil "Edit all lines matching a given regexp" single]) (auctex . [(11 86) nil "Integrated environment for *TeX*" tar]) diff --git a/packages/load-dir-0.0.2.el b/packages/load-dir-0.0.2.el index cec7ce5d5..1d4e0b630 100644 --- a/packages/load-dir-0.0.2.el +++ b/packages/load-dir-0.0.2.el @@ -25,22 +25,18 @@ ;;; Commentary: -;; This library will load all Lisp files found in the `load-dirs' variable. -;; (you may also want to set `load-dir-debug', `load-dir-recursive', -;; and `load-dir-ignore-errors') - -;; Normal usage in .emacs: - -;; (setq load-dirs '("~/mystuff")) ;; or Customize it -;; (require 'load-dir) ;; this will add `load-dirs' to your `after-init-hook' - -;; Then after startup: - -;; Explicitly load new files only... -;; M-x load-dirs - -;; Or reload all your files... -;; M-x load-dirs-reload +;; This package provides a way to load all Emacs Lisp snippets (they +;; don't have to be libraries) in a directory on startup or when Emacs is +;; already running. It won't reload snippets unless the user requests +;; it, so for instance adding a lambda to a hook is usually safe. +;; +;; You can specify ~/.emacs.d/load.d, a single directory, or a list of +;; directories. The file search can be recursive. +;; +;; The intent with ~/.emacs.d/load.d is to give package installers like +;; el-get.el (see https://github.com/dimitri/el-get) and other tools a +;; way to easily bootstrap themselves without necessarily modifying your +;; .emacs or custom files directly. ;;; Code: -- 2.39.2