aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/progmodes/python.el
diff options
context:
space:
mode:
authorStefan Kangas2024-10-05 11:50:34 +0200
committerStefan Kangas2024-10-05 11:50:34 +0200
commit364801fcd66d8e93a900fd750a998f4590d85397 (patch)
tree2a3410d2dab4c9215f63acab76f6ccab305d043d /lisp/progmodes/python.el
parent84c66625e5ef268ec958a04eb61ba8f2beb2ea02 (diff)
downloademacs-364801fcd66d8e93a900fd750a998f4590d85397.tar.gz
emacs-364801fcd66d8e93a900fd750a998f4590d85397.zip
Prefer defvar-keymap in python.el
It's okay to use defvar-keymap here since the 'compat' package backports it for all versions of Emacs that we support (24.4 or later). * lisp/progmodes/python.el (python-mode-map): Prefer defvar-keymap. (python-menu): Move to toplevel.
Diffstat (limited to 'lisp/progmodes/python.el')
-rw-r--r--lisp/progmodes/python.el210
1 files changed, 104 insertions, 106 deletions
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
index c85db018eb1..5532d5f6ce1 100644
--- a/lisp/progmodes/python.el
+++ b/lisp/progmodes/python.el
@@ -334,112 +334,110 @@ To customize the Python interpreter for interactive use, modify
334 334
335;;; Bindings 335;;; Bindings
336 336
337(defvar python-mode-map 337(defvar-keymap python-mode-map
338 (let ((map (make-sparse-keymap))) 338 :doc "Keymap for `python-mode'."
339 ;; Movement 339 ;; Movement
340 (define-key map [remap backward-sentence] #'python-nav-backward-block) 340 "<remap> <backward-sentence>" #'python-nav-backward-block
341 (define-key map [remap forward-sentence] #'python-nav-forward-block) 341 "<remap> <forward-sentence>" #'python-nav-forward-block
342 (define-key map [remap backward-up-list] #'python-nav-backward-up-list) 342 "<remap> <backward-up-list>" #'python-nav-backward-up-list
343 (define-key map [remap up-list] #'python-nav-up-list) 343 "<remap> <up-list>" #'python-nav-up-list
344 (define-key map [remap mark-defun] #'python-mark-defun) 344 "<remap> <mark-defun>" #'python-mark-defun
345 (define-key map "\C-c\C-j" #'imenu) 345 "C-c C-j" #'imenu
346 ;; Indent specific 346 ;; Indent specific
347 (define-key map "\177" #'python-indent-dedent-line-backspace) 347 "DEL" #'python-indent-dedent-line-backspace
348 (define-key map (kbd "<backtab>") #'python-indent-dedent-line) 348 "<backtab>" #'python-indent-dedent-line
349 (define-key map "\C-c<" #'python-indent-shift-left) 349 "C-c <" #'python-indent-shift-left
350 (define-key map "\C-c>" #'python-indent-shift-right) 350 "C-c >" #'python-indent-shift-right
351 ;; Skeletons 351 ;; Skeletons
352 (define-key map "\C-c\C-tc" #'python-skeleton-class) 352 "C-c C-t c" #'python-skeleton-class
353 (define-key map "\C-c\C-td" #'python-skeleton-def) 353 "C-c C-t d" #'python-skeleton-def
354 (define-key map "\C-c\C-tf" #'python-skeleton-for) 354 "C-c C-t f" #'python-skeleton-for
355 (define-key map "\C-c\C-ti" #'python-skeleton-if) 355 "C-c C-t i" #'python-skeleton-if
356 (define-key map "\C-c\C-tm" #'python-skeleton-import) 356 "C-c C-t m" #'python-skeleton-import
357 (define-key map "\C-c\C-tt" #'python-skeleton-try) 357 "C-c C-t t" #'python-skeleton-try
358 (define-key map "\C-c\C-tw" #'python-skeleton-while) 358 "C-c C-t w" #'python-skeleton-while
359 ;; Shell interaction 359 ;; Shell interaction
360 (define-key map "\C-c\C-p" #'run-python) 360 "C-c C-p" #'run-python
361 (define-key map "\C-c\C-s" #'python-shell-send-string) 361 "C-c C-s" #'python-shell-send-string
362 (define-key map "\C-c\C-e" #'python-shell-send-statement) 362 "C-c C-e" #'python-shell-send-statement
363 (define-key map "\C-c\C-r" #'python-shell-send-region) 363 "C-c C-r" #'python-shell-send-region
364 (define-key map "\C-\M-x" #'python-shell-send-defun) 364 "C-M-x" #'python-shell-send-defun
365 (define-key map "\C-c\C-b" #'python-shell-send-block) 365 "C-c C-b" #'python-shell-send-block
366 (define-key map "\C-c\C-c" #'python-shell-send-buffer) 366 "C-c C-c" #'python-shell-send-buffer
367 (define-key map "\C-c\C-l" #'python-shell-send-file) 367 "C-c C-l" #'python-shell-send-file
368 (define-key map "\C-c\C-z" #'python-shell-switch-to-shell) 368 "C-c C-z" #'python-shell-switch-to-shell
369 ;; Some util commands 369 ;; Some util commands
370 (define-key map "\C-c\C-v" #'python-check) 370 "C-c C-v" #'python-check
371 (define-key map "\C-c\C-f" #'python-eldoc-at-point) 371 "C-c C-f" #'python-eldoc-at-point
372 (define-key map "\C-c\C-d" #'python-describe-at-point) 372 "C-c C-d" #'python-describe-at-point
373 ;; Import management 373 ;; Import management
374 (define-key map "\C-c\C-ia" #'python-add-import) 374 "C-c C-i a" #'python-add-import
375 (define-key map "\C-c\C-if" #'python-fix-imports) 375 "C-c C-i f" #'python-fix-imports
376 (define-key map "\C-c\C-ir" #'python-remove-import) 376 "C-c C-i r" #'python-remove-import
377 (define-key map "\C-c\C-is" #'python-sort-imports) 377 "C-c C-i s" #'python-sort-imports
378 ;; Utilities 378 ;; Utilities
379 (substitute-key-definition #'complete-symbol #'completion-at-point 379 "<remap> <complete-symbol>" #'completion-at-point)
380 map global-map) 380
381 (easy-menu-define python-menu map "Python Mode menu" 381(easy-menu-define python-menu python-mode-map
382 '("Python" 382 "Menu used for ´python-mode'."
383 :help "Python-specific Features" 383 '("Python"
384 ["Shift region left" python-indent-shift-left :active mark-active 384 :help "Python-specific Features"
385 :help "Shift region left by a single indentation step"] 385 ["Shift region left" python-indent-shift-left :active mark-active
386 ["Shift region right" python-indent-shift-right :active mark-active 386 :help "Shift region left by a single indentation step"]
387 :help "Shift region right by a single indentation step"] 387 ["Shift region right" python-indent-shift-right :active mark-active
388 "-" 388 :help "Shift region right by a single indentation step"]
389 ["Start of def/class" beginning-of-defun 389 "-----"
390 :help "Go to start of outermost definition around point"] 390 ["Start of def/class" beginning-of-defun
391 ["End of def/class" end-of-defun 391 :help "Go to start of outermost definition around point"]
392 :help "Go to end of definition around point"] 392 ["End of def/class" end-of-defun
393 ["Mark def/class" mark-defun 393 :help "Go to end of definition around point"]
394 :help "Mark outermost definition around point"] 394 ["Mark def/class" mark-defun
395 ["Jump to def/class" imenu 395 :help "Mark outermost definition around point"]
396 :help "Jump to a class or function definition"] 396 ["Jump to def/class" imenu
397 "--" 397 :help "Jump to a class or function definition"]
398 ("Skeletons") 398 "-----"
399 "---" 399 ("Skeletons")
400 ["Start interpreter" run-python 400 "-----"
401 :help "Run inferior Python process in a separate buffer"] 401 ["Start interpreter" run-python
402 ["Switch to shell" python-shell-switch-to-shell 402 :help "Run inferior Python process in a separate buffer"]
403 :help "Switch to running inferior Python process"] 403 ["Switch to shell" python-shell-switch-to-shell
404 ["Eval string" python-shell-send-string 404 :help "Switch to running inferior Python process"]
405 :help "Eval string in inferior Python session"] 405 ["Eval string" python-shell-send-string
406 ["Eval block" python-shell-send-block 406 :help "Eval string in inferior Python session"]
407 :help "Eval block in inferior Python session"] 407 ["Eval block" python-shell-send-block
408 ["Eval buffer" python-shell-send-buffer 408 :help "Eval block in inferior Python session"]
409 :help "Eval buffer in inferior Python session"] 409 ["Eval buffer" python-shell-send-buffer
410 ["Eval statement" python-shell-send-statement 410 :help "Eval buffer in inferior Python session"]
411 :help "Eval statement in inferior Python session"] 411 ["Eval statement" python-shell-send-statement
412 ["Eval region" python-shell-send-region 412 :help "Eval statement in inferior Python session"]
413 :help "Eval region in inferior Python session"] 413 ["Eval region" python-shell-send-region
414 ["Eval defun" python-shell-send-defun 414 :help "Eval region in inferior Python session"]
415 :help "Eval defun in inferior Python session"] 415 ["Eval defun" python-shell-send-defun
416 ["Eval file" python-shell-send-file 416 :help "Eval defun in inferior Python session"]
417 :help "Eval file in inferior Python session"] 417 ["Eval file" python-shell-send-file
418 ["Debugger" pdb :help "Run pdb under GUD"] 418 :help "Eval file in inferior Python session"]
419 "----" 419 ["Debugger" pdb :help "Run pdb under GUD"]
420 ["Check file" python-check 420 "-----"
421 :help "Check file for errors"] 421 ["Check file" python-check
422 ["Help on symbol" python-eldoc-at-point 422 :help "Check file for errors"]
423 :help "Get help on symbol at point"] 423 ["Help on symbol" python-eldoc-at-point
424 ["Complete symbol" completion-at-point 424 :help "Get help on symbol at point"]
425 :help "Complete symbol before point"] 425 ["Complete symbol" completion-at-point
426 "-----" 426 :help "Complete symbol before point"]
427 ["Add import" python-add-import 427 "-----"
428 :help "Add an import statement to the top of this buffer"] 428 ["Add import" python-add-import
429 ["Remove import" python-remove-import 429 :help "Add an import statement to the top of this buffer"]
430 :help "Remove an import statement from the top of this buffer"] 430 ["Remove import" python-remove-import
431 ["Sort imports" python-sort-imports 431 :help "Remove an import statement from the top of this buffer"]
432 :help "Sort the import statements at the top of this buffer"] 432 ["Sort imports" python-sort-imports
433 ["Fix imports" python-fix-imports 433 :help "Sort the import statements at the top of this buffer"]
434 :help "Add missing imports and remove unused ones from the current buffer"] 434 ["Fix imports" python-fix-imports
435 "-----" 435 :help "Add missing imports and remove unused ones from the current buffer"]
436 ("Toggle..." 436 "-----"
437 ["Subword Mode" subword-mode 437 ("Toggle..."
438 :style toggle :selected subword-mode 438 ["Subword Mode" subword-mode
439 :help "Toggle subword movement and editing mode"]) 439 :style toggle :selected subword-mode
440 )) 440 :help "Toggle subword movement and editing mode"])))
441 map)
442 "Keymap for `python-mode'.")
443 441
444(defvar python-ts-mode-map (copy-keymap python-mode-map) 442(defvar python-ts-mode-map (copy-keymap python-mode-map)
445 "Keymap for `(copy-keymap python-mode-map)'.") 443 "Keymap for `(copy-keymap python-mode-map)'.")