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 508k
  • Answers 508k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

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

    • 7 Answers
  • Editorial Team

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

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer First, when creating temp don't just instantiate it as a… May 16, 2026 at 4:17 pm
  • Editorial Team
    Editorial Team added an answer See "Escape Regular Expression Characters in String - JavaScript" for… May 16, 2026 at 4:17 pm
  • Editorial Team
    Editorial Team added an answer Just change it to append the last character rather than… May 16, 2026 at 4:17 pm

Trending Tags

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

Top Members

Related Questions

I use the Python-mode (not the default one comes with emacs 23). I could
I currently use Python for most of my programming, but I'm interested in learning
besides from using a completely integrated IDE with debugger for python (like with Eclipse),
I'm developing a Django app, and I'm trying to use Python's logging module for
I am programming a django based website. I actually use a small computer under
I'm trying to use the python-daemon module. It supplies the daemon.DaemonContext class to properly
FlexBuilder's debugger will show you the memory location (or, I can only assume, something
I'm using the Python 2.5 that came with Mac OS X Snow Leopard (10.6).
I'm working on an application that I need to be cross-platform. I'd like to
I was able to generate python bindings for a camera library using SWIG and

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.