Commits

Anonymous committed 7af5443

implementation of pop_mark(). patch by Darren Hoo

Comments (0)

Files changed (1)

ropemacs/__init__.py

         return lisp.current_word()
 
     def push_mark(self):
-        lisp.push_mark()
+        marker_ring = self.get('marker_ring')
+        marker = lisp.point_marker()
+        lisp.ring_insert(marker_ring, marker)
+
+    def pop_mark(self):
+        marker_ring = self.get('marker_ring')
+        if lisp.ring_empty_p(marker_ring):
+            self.message("There are no more marked buffers in \
+the rope-marker-ring")
+        else:
+            oldbuf = lisp.current_buffer()
+            marker = lisp.ring_remove(marker_ring, 0)
+            marker_buffer = lisp.marker_buffer(marker)
+            if marker_buffer is None:
+                lisp.message("The marked buffer has been deleted")
+                return
+            marker_point  = lisp.marker_position(marker)
+            lisp.set_buffer(marker_buffer)
+            lisp.goto_char(marker_point)
+            #Kill that marker so it doesn't slow down editing.
+            lisp.set_marker(marker, None, None)
+            if not lisp.eq(oldbuf, marker_buffer):
+                lisp.switch_to_buffer(marker_buffer)
 
     def prefix_value(self, prefix):
         return lisp.prefix_numeric_value(prefix)
 
 Use nil to prevent binding keys.")
 
+(defcustom ropemacs-marker-ring-length 16
+  "Length of the rope marker ring.")
+
+(defcustom ropemacs-marker-ring (make-ring ropemacs-marker-ring-length)
+  "Ring of markers which are locations from which goto-definition was invoked.")
+
 (defcustom ropemacs-enable-shortcuts 't
   "Shows whether to bind ropemacs shortcuts keys.
 
 ================  ============================
 M-/               rope-code-assist
 C-c g             rope-goto-definition
+C-c u             rope-pop-mark
 C-c d             rope-show-doc
 C-c f             rope-find-occurrences
 M-?               rope-lucky-assist
                     ["Code assist" rope-code-assist t]
                     ["Lucky assist" rope-lucky-assist t]
                     ["Goto definition" rope-goto-definition t]
+                    ["Pop mark" rope-pop-mark t]
                     ["Jump to global" rope-jump-to-global t]
                     ["Show documentation" rope-show-doc t]
                     ["Find Occurrences" rope-find-occurrences t]
 shortcuts = [('M-/', 'rope-code-assist'),
              ('M-?', 'rope-lucky-assist'),
              ('C-c g', 'rope-goto-definition'),
+             ('C-c u', 'rope-pop-mark'),
              ('C-c d', 'rope-show-doc'),
              ('C-c f', 'rope-find-occurrences')]
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.