diff options
| author | Joakim Verona | 2011-09-19 11:37:46 +0200 |
|---|---|---|
| committer | Joakim Verona | 2011-09-19 11:37:46 +0200 |
| commit | 4caed0bee59613be5d2a6c4afabcdc43222f953e (patch) | |
| tree | d0c1debf666ef2107492e6cdd2bc8d6bb17de8a2 /lisp/replace.el | |
| parent | c139d20a0c582a2c8fe3766128092c32b692ac23 (diff) | |
| parent | c5b01d8c63cfd14c95a029540a6fb0da84537726 (diff) | |
| download | emacs-4caed0bee59613be5d2a6c4afabcdc43222f953e.tar.gz emacs-4caed0bee59613be5d2a6c4afabcdc43222f953e.zip | |
upstream
Diffstat (limited to 'lisp/replace.el')
| -rw-r--r-- | lisp/replace.el | 87 |
1 files changed, 52 insertions, 35 deletions
diff --git a/lisp/replace.el b/lisp/replace.el index 70175cf205c..455e1a511e8 100644 --- a/lisp/replace.el +++ b/lisp/replace.el | |||
| @@ -810,7 +810,7 @@ a previously found match." | |||
| 810 | ;; We use this alternative name, so we can use \\[occur-mode-mouse-goto]. | 810 | ;; We use this alternative name, so we can use \\[occur-mode-mouse-goto]. |
| 811 | (define-key map [mouse-2] 'occur-mode-mouse-goto) | 811 | (define-key map [mouse-2] 'occur-mode-mouse-goto) |
| 812 | (define-key map "\C-c\C-c" 'occur-mode-goto-occurrence) | 812 | (define-key map "\C-c\C-c" 'occur-mode-goto-occurrence) |
| 813 | (define-key map "\C-x\C-q" 'occur-edit-mode) | 813 | (define-key map "e" 'occur-edit-mode) |
| 814 | (define-key map "\C-m" 'occur-mode-goto-occurrence) | 814 | (define-key map "\C-m" 'occur-mode-goto-occurrence) |
| 815 | (define-key map "o" 'occur-mode-goto-occurrence-other-window) | 815 | (define-key map "o" 'occur-mode-goto-occurrence-other-window) |
| 816 | (define-key map "\C-o" 'occur-mode-display-occurrence) | 816 | (define-key map "\C-o" 'occur-mode-display-occurrence) |
| @@ -864,8 +864,8 @@ Alternatively, click \\[occur-mode-mouse-goto] on an item to go to it. | |||
| 864 | (let ((map (make-sparse-keymap))) | 864 | (let ((map (make-sparse-keymap))) |
| 865 | (set-keymap-parent map text-mode-map) | 865 | (set-keymap-parent map text-mode-map) |
| 866 | (define-key map [mouse-2] 'occur-mode-mouse-goto) | 866 | (define-key map [mouse-2] 'occur-mode-mouse-goto) |
| 867 | (define-key map "\C-c\C-c" 'occur-mode-goto-occurrence) | 867 | (define-key map "\C-c\C-c" 'occur-cease-edit) |
| 868 | (define-key map "\C-x\C-q" 'occur-mode) | 868 | (define-key map "\C-o" 'occur-mode-display-occurrence) |
| 869 | (define-key map "\C-c\C-f" 'next-error-follow-minor-mode) | 869 | (define-key map "\C-c\C-f" 'next-error-follow-minor-mode) |
| 870 | (define-key map [menu-bar occur] (cons (purecopy "Occur") occur-menu-map)) | 870 | (define-key map [menu-bar occur] (cons (purecopy "Occur") occur-menu-map)) |
| 871 | map) | 871 | map) |
| @@ -878,40 +878,54 @@ the originating buffer. | |||
| 878 | 878 | ||
| 879 | To return to ordinary Occur mode, use \\[occur-mode]." | 879 | To return to ordinary Occur mode, use \\[occur-mode]." |
| 880 | (setq buffer-read-only nil) | 880 | (setq buffer-read-only nil) |
| 881 | (add-hook 'after-change-functions 'occur-after-change-function nil t)) | 881 | (add-hook 'after-change-functions 'occur-after-change-function nil t) |
| 882 | (message (substitute-command-keys | ||
| 883 | "Editing: Type \\[occur-cease-edit] to return to Occur mode."))) | ||
| 884 | |||
| 885 | (defun occur-cease-edit () | ||
| 886 | "Switch from Occur Edit mode to Occur mode." | ||
| 887 | (interactive) | ||
| 888 | (when (derived-mode-p 'occur-edit-mode) | ||
| 889 | (occur-mode) | ||
| 890 | (message "Switching to Occur mode."))) | ||
| 882 | 891 | ||
| 883 | (defun occur-after-change-function (beg end length) | 892 | (defun occur-after-change-function (beg end length) |
| 884 | (save-excursion | 893 | (save-excursion |
| 885 | (goto-char beg) | 894 | (goto-char beg) |
| 886 | (let* ((m (get-text-property (line-beginning-position) 'occur-target)) | 895 | (let* ((line-beg (line-beginning-position)) |
| 896 | (m (get-text-property line-beg 'occur-target)) | ||
| 887 | (buf (marker-buffer m)) | 897 | (buf (marker-buffer m)) |
| 888 | (col (current-column))) | 898 | col) |
| 889 | (when (= length 0) | 899 | (when (and (get-text-property line-beg 'occur-prefix) |
| 890 | ;; Apply occur-target property to inserted (e.g. yanked) text. | 900 | (not (get-text-property end 'occur-prefix))) |
| 891 | (put-text-property beg end 'occur-target m) | 901 | (when (= length 0) |
| 892 | ;; Did we insert a newline? Occur Edit mode can't create new | 902 | ;; Apply occur-target property to inserted (e.g. yanked) text. |
| 893 | ;; Occur entries; just discard everything after the newline. | 903 | (put-text-property beg end 'occur-target m) |
| 894 | (save-excursion | 904 | ;; Did we insert a newline? Occur Edit mode can't create new |
| 895 | (and (search-forward "\n" end t) | 905 | ;; Occur entries; just discard everything after the newline. |
| 896 | (delete-region (1- (point)) end)))) | 906 | (save-excursion |
| 897 | (let ((line (- (line-number-at-pos) | 907 | (and (search-forward "\n" end t) |
| 898 | (line-number-at-pos (window-start)))) | 908 | (delete-region (1- (point)) end)))) |
| 899 | (readonly (with-current-buffer buf buffer-read-only)) | 909 | (let* ((line (- (line-number-at-pos) |
| 900 | (win (or (get-buffer-window buf) | 910 | (line-number-at-pos (window-start)))) |
| 901 | (display-buffer buf t))) | 911 | (readonly (with-current-buffer buf buffer-read-only)) |
| 902 | (text (save-excursion | 912 | (win (or (get-buffer-window buf) |
| 903 | (forward-line 0) | 913 | (display-buffer buf t))) |
| 904 | (search-forward ":" nil t) | 914 | (line-end (line-end-position)) |
| 905 | (setq col (- col (current-column))) | 915 | (text (save-excursion |
| 906 | (buffer-substring-no-properties (point) (line-end-position))))) | 916 | (goto-char (next-single-property-change |
| 907 | (with-selected-window win | 917 | line-beg 'occur-prefix nil |
| 908 | (goto-char m) | 918 | line-end)) |
| 909 | (recenter line) | 919 | (setq col (- (point) line-beg)) |
| 910 | (if readonly | 920 | (buffer-substring-no-properties (point) line-end)))) |
| 911 | (message "Buffer `%s' is read only." buf) | 921 | (with-selected-window win |
| 912 | (delete-region (line-beginning-position) (line-end-position)) | 922 | (goto-char m) |
| 913 | (insert text)) | 923 | (recenter line) |
| 914 | (move-to-column col)))))) | 924 | (if readonly |
| 925 | (message "Buffer `%s' is read only." buf) | ||
| 926 | (delete-region (line-beginning-position) (line-end-position)) | ||
| 927 | (insert text)) | ||
| 928 | (move-to-column col))))))) | ||
| 915 | 929 | ||
| 916 | 930 | ||
| 917 | (defun occur-revert-function (_ignore1 _ignore2) | 931 | (defun occur-revert-function (_ignore1 _ignore2) |
| @@ -1336,9 +1350,12 @@ See also `multi-occur'." | |||
| 1336 | (when prefix-face | 1350 | (when prefix-face |
| 1337 | `(font-lock-face prefix-face)) | 1351 | `(font-lock-face prefix-face)) |
| 1338 | `(occur-prefix t mouse-face (highlight) | 1352 | `(occur-prefix t mouse-face (highlight) |
| 1339 | occur-target ,marker follow-link t | 1353 | ;; Allow insertion of text at |
| 1340 | read-only t | 1354 | ;; the end of the prefix (for |
| 1341 | help-echo "mouse-2: go to this occurrence")))) | 1355 | ;; Occur Edit mode). |
| 1356 | front-sticky t rear-nonsticky t | ||
| 1357 | occur-target ,marker follow-link t | ||
| 1358 | help-echo "mouse-2: go to this occurrence")))) | ||
| 1342 | (match-str | 1359 | (match-str |
| 1343 | ;; We don't put `mouse-face' on the newline, | 1360 | ;; We don't put `mouse-face' on the newline, |
| 1344 | ;; because that loses. And don't put it | 1361 | ;; because that loses. And don't put it |