Find where you left off...

Toby J Sargeant tjs at cs.monash.edu.au
Thu Jul 27 06:12:49 EDT 2000


On Thu, Jul 27, 2000 at 08:06:33AM +0000, QuoteMstr wrote:
> In article <397F7BF5.F4A0138D at yahoo.com>, Paul Winkler wrote:
> >A little trick I discovered today:
> >when writing python in emacs, you can mark the spot where you
> >stopped just by writing some arbitrary text like "start from here"
> >or whatever. Next time you open this file in emacs, just do C-c C-c
> >; python throws an exception and emacs jumps to the offending line.
> 
> That's a dangerous practice. Python doesn't catch all such errors when
> the script executes. If you put the error inside a function that isn't
> called except under special, rare circumstances, you won't notice
> until you encounter it. Furthermore, if you forget about an error, it
> will stay there, as a bug, until someone tries to execute the
> offending piece of code.

Also, emacs saves bookmarks when you quit, which is really handy for doing
exactly this kind of thing. I use the following code:

(defmacro define-key-as-bookmark (mark-key jump-key label)
  (` (
      progn
       (define-key global-map (, mark-key)
	 (function (lambda () "" (interactive)
		     (bookmark-set (, label))
		     (message (concat "Set Bookmark " (, label))))))
       (define-key global-map (, jump-key)
	 (function (lambda () "" (interactive)
		     (bookmark-jump (, label))))))
     ))

followed by:

(global-unset-key "\C-z")
(global-unset-key [?\C-z ?\C-z])

(define-key-as-bookmark [?\C-z ?\C-z 97] [?\C-z 97] "mark-a")
(define-key-as-bookmark [?\C-z ?\C-z 98] [?\C-z 98] "mark-b")
(define-key-as-bookmark [?\C-z ?\C-z 99] [?\C-z 99] "mark-c")
... etc

to provide functionality similar to vi's ma and `a commands, which allow me
to type C-Z C-Z [letter] to place a bookmark, and C-Z [letter] to jump back to
it. (C-Z is probably not the best choice if you're using a console based
emacs, but it's in a good location on the keyboard, so...)

Toby.




More information about the Python-list mailing list