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

  • SEARCH
  • Home
  • 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 643023
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T21:14:16+00:00 2026-05-13T21:14:16+00:00

I use python debugger pdb. I use emacs for python programming. I use python-mode.el.

  • 0

I use python debugger pdb. I use emacs for python programming. I use python-mode.el. My idea is to make emacs intuitive. So I need the following help for python programs (.py)

  1. Whenever I press ‘F9’ key, the emacs should put “import pdb; pdb.set_trace();” statements in the current line and move the current line to one line below.
    Sentence to be in same line. smart indentation may help very much.

  2. Wherever “import pdb; pdb.set_trace();” statement presents in the python code, emacs should display left indicator and highlight that line.

  3. When I press ‘Alt-F9’ keys at the current line and emacs found the “import pdb; pdb.set_trace();” statement then, emacs should remove the “import pdb; pdb.set_trace();” line and move the current line to one up.

  4. Whenever I press “F8” key, emacs to jump to “import pdb; pdb.set_trace();” in the same buffer.

I am trying to learn elisp and catch up lisp soon to customize emacs myself. I will appreciate your answers.

The answer shall be great enough for me and others who find this solution is very useful.

  • 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-13T21:14:17+00:00Added an answer on May 13, 2026 at 9:14 pm

    to do 1)

    (defun add-py-debug ()  
          "add debug code and move line down"  
        (interactive)  
        (move-beginning-of-line 1)  
        (insert "import pdb; pdb.set_trace();\n"))  
    
    (local-set-key (kbd "<f9>") 'add-py-debug)
    

    to do 2) you probably have to change the syntax highlighting of the python mode, or write you own minor mode. You’d have to look into font-lock to get more. Sorry.

    to do 3) though I’ve set this to be C-c F9 instead of Alt-F9

    (defun remove-py-debug ()  
      "remove py debug code, if found"  
      (interactive)  
      (let ((x (line-number-at-pos))  
        (cur (point)))  
        (search-forward-regexp "^[ ]*import pdb; pdb.set_trace();")  
        (if (= x (line-number-at-pos))  
        (let ()  
          (move-beginning-of-line 1)  
          (kill-line 1)  
          (move-beginning-of-line 1))  
          (goto-char cur))))  
    
    (local-set-key (kbd "C c <f9>") 'remove-py-debug)
    

    and to do 4)

    (local-set-key (kbd "<f3>") '(lambda ()  
                                     (interactive)   
                                     (search-forward-regexp "^[ ]*import pdb; pdb.set_trace();")   
                                     (move-beginning-of-line 1)))
    

    Note, this is not the best elisp code in the world, but I’ve tried to make it clear to you what’s going on rather than make it totally idiomatic. The GNU Elsip book is a great place to start if you want to do more with elisp.

    HTH

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

Sidebar

Ask A Question

Stats

  • Questions 418k
  • Answers 418k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Your requirements seem a bit vague, so it is hard… May 15, 2026 at 9:58 am
  • Editorial Team
    Editorial Team added an answer hg pull pulls down new changesets from a remote repository… May 15, 2026 at 9:58 am
  • Editorial Team
    Editorial Team added an answer Try Console.WriteLine("Enter any Key: "); ConsoleKeyInfo name = Console.ReadKey(); Console.WriteLine("You… May 15, 2026 at 9:58 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.