emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] /srv/bzr/emacs/trunk r105812: * lisp/replace.el (occur-mod


From: Chong Yidong
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r105812: * lisp/replace.el (occur-mode-map): Rebind occur-edit-mode to "e".
Date: Sat, 17 Sep 2011 17:28:17 -0400
User-agent: Bazaar (2.3.1)

------------------------------------------------------------
revno: 105812
fixes bug(s): http://debbugs.gnu.org/8463
committer: Chong Yidong <address@hidden>
branch nick: trunk
timestamp: Sat 2011-09-17 17:28:17 -0400
message:
  * lisp/replace.el (occur-mode-map): Rebind occur-edit-mode to "e".
  (occur-edit-mode-map): Bind C-c C-c to occur-cease-edit and C-o to
  occur-mode-display-occurrence.
  (occur-edit-mode): Add usage message.
  (occur-cease-edit): New command.
  (occur-after-change-function): Use text properties to find the
  position of the prefix text.
  (occur-engine): Set stickiness of prefix text properties.
modified:
  etc/NEWS
  lisp/ChangeLog
  lisp/net/ldap.el
  lisp/replace.el
=== modified file 'etc/NEWS'
--- a/etc/NEWS  2011-09-11 20:27:29 +0000
+++ b/etc/NEWS  2011-09-17 21:28:17 +0000
@@ -814,7 +814,7 @@
 * New Modes and Packages in Emacs 24.1
 
 ** Occur Edit mode applies edits made in *Occur* buffers to the
-original buffers.  It is bound to C-x C-q in Occur mode.
+original buffers.  It is bound to "e" in Occur mode.
 
 ** New global minor modes electric-pair-mode, electric-indent-mode,
 and electric-layout-mode.

=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2011-09-17 19:05:52 +0000
+++ b/lisp/ChangeLog    2011-09-17 21:28:17 +0000
@@ -1,3 +1,14 @@
+2011-09-17  Chong Yidong  <address@hidden>
+
+       * replace.el (occur-mode-map): Rebind occur-edit-mode to "e" (Bug#8463).
+       (occur-edit-mode-map): Bind C-c C-c to occur-cease-edit and C-o to
+       occur-mode-display-occurrence.
+       (occur-edit-mode): Add usage message.
+       (occur-cease-edit): New command.
+       (occur-after-change-function): Use text properties to find the
+       position of the prefix text.
+       (occur-engine): Set stickiness of prefix text properties.
+
 2011-09-17  Glenn Morris  <address@hidden>
 
        * progmodes/etags.el (complete-tag):

=== modified file 'lisp/net/ldap.el'
--- a/lisp/net/ldap.el  2011-05-10 13:57:12 +0000
+++ b/lisp/net/ldap.el  2011-09-17 21:28:17 +0000
@@ -632,9 +632,10 @@
            (setq record (cons (list name value)
                               record))
            (forward-line 1))
-         (push (if withdn
-                   (cons dn (nreverse record))
-                 (nreverse record)) result)
+         (cond (withdn
+                (push (cons dn (nreverse record)) result))
+               (record
+                (push (nreverse record) result)))
          (setq record nil)
          (skip-chars-forward " \t\n")
          (message "Parsing results... %d" numres)

=== modified file 'lisp/replace.el'
--- a/lisp/replace.el   2011-09-14 15:14:34 +0000
+++ b/lisp/replace.el   2011-09-17 21:28:17 +0000
@@ -810,7 +810,7 @@
     ;; We use this alternative name, so we can use \\[occur-mode-mouse-goto].
     (define-key map [mouse-2] 'occur-mode-mouse-goto)
     (define-key map "\C-c\C-c" 'occur-mode-goto-occurrence)
-    (define-key map "\C-x\C-q" 'occur-edit-mode)
+    (define-key map "e" 'occur-edit-mode)
     (define-key map "\C-m" 'occur-mode-goto-occurrence)
     (define-key map "o" 'occur-mode-goto-occurrence-other-window)
     (define-key map "\C-o" 'occur-mode-display-occurrence)
@@ -864,8 +864,8 @@
   (let ((map (make-sparse-keymap)))
     (set-keymap-parent map text-mode-map)
     (define-key map [mouse-2] 'occur-mode-mouse-goto)
-    (define-key map "\C-c\C-c" 'occur-mode-goto-occurrence)
-    (define-key map "\C-x\C-q" 'occur-mode)
+    (define-key map "\C-c\C-c" 'occur-cease-edit)
+    (define-key map "\C-o" 'occur-mode-display-occurrence)
     (define-key map "\C-c\C-f" 'next-error-follow-minor-mode)
     (define-key map [menu-bar occur] (cons (purecopy "Occur") occur-menu-map))
     map)
@@ -878,40 +878,54 @@
 
 To return to ordinary Occur mode, use \\[occur-mode]."
   (setq buffer-read-only nil)
-  (add-hook 'after-change-functions 'occur-after-change-function nil t))
+  (add-hook 'after-change-functions 'occur-after-change-function nil t)
+  (message (substitute-command-keys
+           "Editing: Type \\[occur-cease-edit] to return to Occur mode.")))
+
+(defun occur-cease-edit ()
+  "Switch from Occur Edit mode to Occur mode."
+  (interactive)
+  (when (derived-mode-p 'occur-edit-mode)
+    (occur-mode)
+    (message "Switching to Occur mode.")))
 
 (defun occur-after-change-function (beg end length)
   (save-excursion
     (goto-char beg)
-    (let* ((m (get-text-property (line-beginning-position) 'occur-target))
+    (let* ((line-beg (line-beginning-position))
+          (m (get-text-property line-beg 'occur-target))
           (buf (marker-buffer m))
-          (col (current-column)))
-      (when (= length 0)
-       ;; Apply occur-target property to inserted (e.g. yanked) text.
-       (put-text-property beg end 'occur-target m)
-       ;; Did we insert a newline?  Occur Edit mode can't create new
-       ;; Occur entries; just discard everything after the newline.
-       (save-excursion
-         (and (search-forward "\n" end t)
-              (delete-region (1- (point)) end))))
-      (let ((line (- (line-number-at-pos)
-                    (line-number-at-pos (window-start))))
-           (readonly (with-current-buffer buf buffer-read-only))
-           (win (or (get-buffer-window buf)
-                    (display-buffer buf t)))
-           (text (save-excursion
-                   (forward-line 0)
-                   (search-forward ":" nil t)
-                   (setq col (- col (current-column)))
-                   (buffer-substring-no-properties (point) 
(line-end-position)))))
-       (with-selected-window win
-         (goto-char m)
-         (recenter line)
-         (if readonly
-             (message "Buffer `%s' is read only." buf)
-           (delete-region (line-beginning-position) (line-end-position))
-           (insert text))
-         (move-to-column col))))))
+          col)
+      (when (and (get-text-property line-beg 'occur-prefix)
+                (not (get-text-property end 'occur-prefix)))
+       (when (= length 0)
+         ;; Apply occur-target property to inserted (e.g. yanked) text.
+         (put-text-property beg end 'occur-target m)
+         ;; Did we insert a newline?  Occur Edit mode can't create new
+         ;; Occur entries; just discard everything after the newline.
+         (save-excursion
+           (and (search-forward "\n" end t)
+                (delete-region (1- (point)) end))))
+       (let* ((line (- (line-number-at-pos)
+                       (line-number-at-pos (window-start))))
+              (readonly (with-current-buffer buf buffer-read-only))
+              (win (or (get-buffer-window buf)
+                       (display-buffer buf t)))
+              (line-end (line-end-position))
+              (text (save-excursion
+                      (goto-char (next-single-property-change
+                                  line-beg 'occur-prefix nil
+                                  line-end))
+                      (setq col (- (point) line-beg))
+                      (buffer-substring-no-properties (point) line-end))))
+         (with-selected-window win
+           (goto-char m)
+           (recenter line)
+           (if readonly
+               (message "Buffer `%s' is read only." buf)
+             (delete-region (line-beginning-position) (line-end-position))
+             (insert text))
+           (move-to-column col)))))))
 
 
 (defun occur-revert-function (_ignore1 _ignore2)
@@ -1336,9 +1350,12 @@
                                    (when prefix-face
                                      `(font-lock-face prefix-face))
                                    `(occur-prefix t mouse-face (highlight)
-                                                  occur-target ,marker 
follow-link t
-                                                  read-only t
-                                                  help-echo "mouse-2: go to 
this occurrence"))))
+                                     ;; Allow insertion of text at
+                                     ;; the end of the prefix (for
+                                     ;; Occur Edit mode).
+                                     front-sticky t rear-nonsticky t
+                                     occur-target ,marker follow-link t
+                                     help-echo "mouse-2: go to this 
occurrence"))))
                           (match-str
                            ;; We don't put `mouse-face' on the newline,
                            ;; because that loses.  And don't put it


reply via email to

[Prev in Thread] Current Thread [Next in Thread]