I am using rope-goto-definition to jump into a module's definition, link. But I cannot jump back to where I was. xref-pop-marker-stack says Marker stack is empty. Is it possible to jump back after running rope-goto-definition? Similiar behavior is done using jedi:goto-definition-pop-marker.

My setup:

(require 'pymacs)
(pymacs-load "ropemacs" "rope-")
(setq ropemacs-enable-autoimport 't)
(setq ropemacs-autoimport-modules '("os" "shutil"))

(defun goto-def-or-jedi ()
  "Go to definition of thing at point or do an rgrep in project if that fails"
  (condition-case nil (rope-goto-definition)
    (error (rope-goto-definition (thing-at-point 'symbol)))))

Note: On there github its said that: ropemacs is completely unmaintained and abandoned. link. So there is no hope to have support from developers. Maybe before jump, the location can be pushed into the stack?

  • Is it any particular reason to use rope? With lsp + python, xref-pop-marker-stack works flawlessly.
    – Ian
    Mar 8 at 14:46
  • just rope has auto-import option but actually no. I just want to jump into definition and get back. I wasn't able to setup of lsp + python for that that's why I also end up in rope. How can I use lsp +python to jump into module definitions?
    – alper
    Mar 8 at 15:07
  • 1
    I do not know what you tried with lsp, here are two steps to check the combination lsp+python: First install python-language-server as described [github.com/palantir/python-language-server/blob/develop/…, including all 3rd party plugins. (install [all]).
    – Ian
    Mar 9 at 12:31
  • 1
    Clone [github.com/rksm/emacs-rust-config] this package to check/play with lsp , it does not interfere with your emacs configuration - while this is written for rust, before installing it, just edit the file init.el and comment out the lines 9..35 and 48 and add the following (use-package python :ensure nil), save and install packages. Then open a python file, and M-x lsp to start lsp, M-x lsp-find-definiton of a function and M-x xref-pop-marker-stack to return to source file. Or use the already binded keys s-l g g and M-,.
    – Ian
    Mar 9 at 12:32
  • Should I add (use-package python :ensure nil), to line 9 ? including ,? How can I install it afterwards? like (load "standalone.el")?
    – alper
    Mar 9 at 19:38

you can put a mark at rope-goto-definition with https://www.emacswiki.org/emacs/auto-mark.el

(require 'auto-mark)
  (setq auto-mark-command-class-alist
        '((anything . anything)
          (rope-goto-definition . jump)
          (indent-for-tab-command . ignore)
          (undo . ignore)))
  (setq auto-mark-command-classifiers
        (list (lambda (command)
                (if (and (eq command 'self-insert-command)
                         (eq last-command-event ? ))
  (global-auto-mark-mode 1)

Then you can use pop-global-mark or pop-local-mark depending on whether there is a change of buffer or not. unfortunately with this solution it is up to the user to manage when to use local or global marks.

  • 1
    Please, make it into pull request against github.com/python-rope/ropemacs
    – mcepl
    Mar 13 at 14:47
  • @mcepl This "solution" is a workaround... I don't think it's a good idea to integrate this code. If we want this evolution in ropemacs, we will have to take the time to do it properly.
    – djangoliv
    Mar 15 at 7:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.