Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6157637
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T20:49:11+00:00 2026-05-23T20:49:11+00:00

For example, I have the file model/user.py open and I want to have a

  • 0

For example, I have the file model/user.py open and I want to have a shortcut that opens controller/user.py. Or I want to switch to test/model/testUser.py (contrived example)

I’d like to make an emacs shortcut which given a file currently open, opens files related in various ways.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T20:49:12+00:00Added an answer on May 23, 2026 at 8:49 pm

    If the “related files” follow some kind of pattern, I think it’s trivial to write some elisp functions to do the task. Let’s say you have a model and need to open his associated controller, you will need to do something like this:

    (defun my-open-related-controller ()
      (interactive)
      (let* ((name (buffer-file-name))) ;gets the filename of the current buffer
        ;; Of course, this is only an example. The point here is that you need
        ;; to "discover" the name of the related file based on the current one.
        (setf name (replace-regexp-in-string "model" "controller" name))
    
        ;; Now you will open the file(if it isn't open already) and switch to it
        (find-file name)))
    

    Then you can bind the function to, say, F5:

    (define-key name-of-the-mode-map [f5] 'my-open-related-controller)
    

    If you want to crate this binding globally, use:

    (global-set-key [f5] 'my-open-related-controller)
    

    Of course, this is just a crude example(since you didn’t give many specific details), but should be enough to get you started. Hope it helps!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For example, suppose I have a batch file called 'test.cmd' and it simply contains:
Is it possible to have a file belong to multiple subpackages? For example: /**
I have a text file with dos elements - hex(00) for example. I need
If I have a collection of database tables (in an Access file, for example)
For example, if I have a page located in Views/Home/Index.aspx and a JavaScript file
I used to have one class for one file. For example car.cs has the
Example: You have a shortcut s to SomeProgram in the current directory. In cmd.exe
Example I have Person , SpecialPerson , and User . Person and SpecialPerson are
For example I have this gem called Authlogic-openid, that plugin is outdated, no longer
I have a WinForm and few properties that are set on it. for example

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.