1. Matt McClure
  2. ropemacs


angri  committed 7af5443

implementation of pop_mark(). patch by Darren Hoo

  • Participants
  • Parent commits 7ec8079
  • Branches trunk

Comments (0)

Files changed (1)

File ropemacs/__init__.py

View file
  • Ignore whitespace
         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')]