-
-
Notifications
You must be signed in to change notification settings - Fork 20
/
python-mode.el
26187 lines (21938 loc) · 938 KB
/
python-mode.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
;;; python-mode.el --- Edit, debug, develop, run Python programs. -*- lexical-binding: t; -*-
;; Version: 6.3.1
;; URL: https://gitlab.com/groups/python-mode-devs
;; Package-Requires: ((emacs "24"))
;; Author: 2015-2023 https://gitlab.com/groups/python-mode-devs
;; 2003-2014 https://launchpad.net/python-mode
;; 1995-2002 Barry A. Warsaw
;; 1992-1994 Tim Peters
;; Maintainer: [email protected]
;; Created: Feb 1992
;; Keywords: python languages oop
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
;;; Commentary:
;; Includes a minor mode for handling a Python/IPython shell, and can
;; take advantage of Pymacs when installed.
;; See documentation in README.org, README.DEVEL.org
;; Please report bugs at
;; https://gitlab.com/python-mode-devs/python-mode/issues
;; available commands are documented in directory "doc" as
;; commands-python-mode.org
;; As for ‘py-add-abbrev’:
;; Similar to ‘add-mode-abbrev’, but uses
;; ‘py-partial-expression’ before point for expansion to
;; store, not ‘word’. Also provides a proposal for new
;; abbrevs.
;; Proposal for an abbrev is composed from the downcased
;; initials of expansion - provided they are of char-class
;; [:alpha:]
;;
;; For example code below would be recognised as a
;; ‘py-expression’ composed by three
;; py-partial-expressions.
;;
;; OrderedDict.popitem(last=True)
;;
;; Putting the curser at the EOL, M-3 M-x py-add-abbrev
;;
;; would prompt "op" for an abbrev to store, as first
;; ‘py-partial-expression’ beginns with a "(", which is
;; not taken as proposal.
;;; Code:
(require 'ansi-color)
(ignore-errors (require 'subr-x))
(require 'cc-cmds)
(require 'comint)
(require 'compile)
(require 'custom)
(require 'ert)
(require 'flymake)
(require 'hippie-exp)
(require 'hideshow)
(require 'json)
(require 'shell)
(require 'thingatpt)
(require 'which-func)
(require 'tramp)
(require 'tramp-sh)
(require 'org-loaddefs)
(unless (functionp 'mapcan)
(require 'cl-extra)
;; mapcan doesn't exist in Emacs 25
(defalias 'mapcan 'cl-mapcan)
)
;; (require 'org)
(defgroup python-mode nil
"Support for the Python programming language, <http://www.python.org/>"
:group 'languages
:prefix "py-")
(defconst py-version "6.3.1")
(defvar py-install-directory nil
"Make sure it exists.")
(defcustom py-install-directory nil
"Directory where python-mode.el and it's subdirectories should be installed.
Needed for completion and other environment stuff only."
:type 'string
:tag "py-install-directory"
:group 'python-mode)
(or
py-install-directory
(and (buffer-live-p (ignore-errors (set-buffer (get-buffer "python--mode.el"))))
(setq py-install-directory (ignore-errors (file-name-directory (buffer-file-name (get-buffer "python-mode.el"))))))
(and (buffer-live-p (ignore-errors (set-buffer (get-buffer "python-components-mode.el"))))
(setq py-install-directory (ignore-errors (file-name-directory (buffer-file-name (get-buffer "python-components-mode.el")))))))
(defcustom py-font-lock-defaults-p t
"If fontification is not required, avoiding it might speed up things."
:type 'boolean
:tag "py-font-lock-defaults-p"
:group 'python-mode
:safe 'booleanp)
(defcustom py-register-shell-buffer-p nil
"If non-nil, register new py-shell according to py-register-char as REGISTER.
Default is nil.
See ‘window-configuration-to-register’"
:type 'boolean
:tag "py-register-shell-buffer-p"
:group 'python-mode
:safe 'booleanp)
(defcustom py-register-char ?y
"Char used by py-register-shell-buffer-p
Default is ‘y’.
See also ‘window-configuration-to-register’"
:type 'char
:tag "py-register-char"
:group 'python-mode
:safe 'characterp)
(defcustom py-pythonpath ""
"Define $PYTHONPATH here, if needed.
Emacs doesn't read .bashrc"
:type 'string
:tag "py-pythonpath"
:group 'python-mode)
(defcustom python-mode-modeline-display "Py"
"String to display in Emacs modeline."
:type 'string
:tag "python-mode-modeline-display"
:group 'python-mode)
(defcustom py-python2-modeline-display "Py2"
"String to display in Emacs modeline."
:type 'string
:tag "python2-mode-modeline-display"
:group 'python-mode)
(defcustom py-python3-modeline-display "Py3"
"String to display in Emacs modeline."
:type 'string
:tag "python3-mode-modeline-display"
:group 'python-mode)
(defcustom py-ipython-modeline-display "IPy"
"String to display in Emacs modeline."
:type 'string
:tag "ipython-modeline-display"
:group 'python-mode)
(defcustom py-jython-modeline-display "Jy"
"String to display in Emacs modeline."
:type 'string
:tag "jython-modeline-display"
:group 'python-mode)
(defcustom py-extensions "py-extensions.el"
"File where extensions to python-mode.el should be installed.
Used by virtualenv support."
:type 'string
:tag "py-extensions"
:group 'python-mode)
(defcustom info-lookup-mode "python"
"Which Python documentation should be queried.
Make sure it's accessible from Emacs by \\<emacs-lisp-mode-map> \\[info] ...
See INSTALL-INFO-FILES for help."
:type 'string
:tag "info-lookup-mode"
:group 'python-mode)
(defcustom py-fast-process-p nil
"Use ‘py-fast-process’.
Commands prefixed \"py-fast-...\" suitable for large output
See: large output makes Emacs freeze, lp:1253907
Results arrive in output buffer, which is not in comint-mode"
:type 'boolean
:tag "py-fast-process-p"
:group 'python-mode
:safe 'booleanp)
;; credits to python.el
(defcustom py-shell-compilation-regexp-alist
`((,(rx line-start (1+ (any " \t")) "File \""
(group (1+ (not (any "\"<")))) ; avoid `<stdin>' &c
"\", line " (group (1+ digit)))
1 2)
(,(rx " in file " (group (1+ not-newline)) " on line "
(group (1+ digit)))
1 2)
(,(rx line-start "> " (group (1+ (not (any "(\"<"))))
"(" (group (1+ digit)) ")" (1+ (not (any "("))) "()")
1 2))
"‘compilation-error-regexp-alist’ for ‘py-shell’."
:type '(alist string)
:tag "py-shell-compilation-regexp-alist"
:group 'python-mode)
(defcustom py-shift-require-transient-mark-mode-p t
"If py-shift commands require variable ‘transient-mark-mode’ set to t.
Default is t"
:type 'boolean
:tag "py-shift-require-transient-mark-mode-p"
:group 'python-mode
:safe 'booleanp)
(defvar py-fast-output-buffer "*Python Fast*"
"Internally used. ‘buffer-name’ for fast-processes.")
(defvar py-this-result nil
"Internally used, store return-value.")
(defconst py-coding-re
"\\(# *coding[ \t]*=\\|#[ \t]*\-*\-[ \t]*coding:\\|#[ \t]*encoding:\\)[ \t]*\\([[:graph:]+]\\)"
"Fetch the coding cookie maybe.")
(defcustom py-comment-auto-fill-p nil
"When non-nil, fill comments.
Defaut is nil"
:type 'boolean
:tag "py-comment-auto-fill-p"
:group 'python-mode
:safe 'booleanp)
(defcustom py-sexp-use-expression-p nil
"If non-nil, ‘forward-sexp’ will call ‘py-forward-expression’.
Respective ‘backward-sexp’ will call ‘py-backward-expression’
Default is t"
:type 'boolean
:tag "py-sexp-use-expression-p"
:group 'python-mode
:safe 'booleanp)
(defcustom py-session-p t
"If commands would use an existing process.
Default is t"
:type 'boolean
:tag "py-session-p"
:group 'python-mode
:safe 'booleanp)
(defvar py-chars-before " \t\n\r\f"
"Used by ‘py--string-strip’.")
(defvar py-chars-after " \t\n\r\f"
"Used by ‘py--string-strip’.")
(unless (functionp 'file-local-name)
(defun file-local-name (file)
"Return the local name component of FILE.
This function removes from FILE the specification of the remote host
and the method of accessing the host, leaving only the part that
identifies FILE locally on the remote system.
The returned file name can be used directly as argument of
‘process-file’, ‘start-file-process’, or ‘shell-command’."
(or (file-remote-p file 'localname) file)))
(defun py---emacs-version-greater-23 ()
"Return ‘t’ if emacs major version is above 23"
(< 23 (string-to-number (car (split-string emacs-version "\\.")))))
;; (format "execfile(r'%s')\n" file)
(defun py-execute-file-command (filename)
"Return the command using FILENAME."
(format "exec(compile(open(r'%s').read(), r'%s', 'exec')) # PYTHON-MODE\n" filename filename)
)
(defun py--beginning-of-buffer-p ()
"Returns position, if cursor is at the beginning of buffer.
Return nil otherwise. "
(when (bobp)(point)))
;; (setq strip-chars-before "[ \t\r\n]*")
(defun py--string-strip (str &optional chars-before chars-after)
"Return a copy of STR, CHARS removed.
Removed chars default to values of ‘py-chars-before’ and ‘py-chars-after’
i.e. spaces, tabs, carriage returns, newlines and newpages
Optional arguments `CHARS-BEFORE' and `CHARS-AFTER' override default"
(let ((s-c-b (or chars-before
py-chars-before))
(s-c-a (or chars-after
py-chars-after))
(erg str))
(setq erg (replace-regexp-in-string s-c-b "" erg))
(setq erg (replace-regexp-in-string s-c-a "" erg))
erg))
(defun py-toggle-session-p (&optional arg)
"Switch boolean variable ‘py-session-p’.
With optional ARG message state switched to"
(interactive "p")
(setq py-session-p (not py-session-p))
(when arg (message "py-session-p: %s" py-session-p)))
(defcustom py-max-help-buffer-p nil
"If \"\*Python-Help\*\"-buffer should appear as the only visible.
Default is nil. In ‘help-buffer’, \"q\" will close it."
:type 'boolean
:tag "py-max-help-buffer-p"
:group 'python-mode
:safe 'booleanp)
(defcustom py-highlight-error-source-p nil
"Respective code in source-buffer will be highlighted.
Default is nil.
\\<python-mode-map> ‘py-remove-overlays-at-point’ removes that highlighting."
:type 'boolean
:tag "py-highlight-error-source-p"
:group 'python-mode)
(defcustom py-set-pager-cat-p nil
"If the shell environment variable $PAGER should set to ‘cat’.
Avoids lp:783828,
\"Terminal not fully functional\", for help('COMMAND') in python-shell
When non-nil, imports module ‘os’"
:type 'boolean
:tag "py-set-pager-cat-p"
:group 'python-mode)
(defcustom py-empty-line-closes-p nil
"When non-nil, dedent after empty line following block.
if True:
print(\"Part of the if-statement\")
print(\"Not part of the if-statement\")
Default is nil"
:type 'boolean
:tag "py-empty-line-closes-p"
:group 'python-mode)
(defcustom py-prompt-on-changed-p t
"Ask for save before a changed buffer is sent to interpreter.
Default is t"
:type 'boolean
:tag "py-prompt-on-changed-p"
:group 'python-mode)
(defcustom py-dedicated-process-p nil
"If commands executing code use a dedicated shell.
Default is nil
When non-nil and ‘py-session-p’, an existing
dedicated process is re-used instead of default
- which allows executing stuff in parallel."
:type 'boolean
:tag "py-dedicated-process-p"
:group 'python-mode)
(defcustom py-store-result-p nil
"Put resulting string of `py-execute-...' into ‘kill-ring’.
Default is nil"
:type 'boolean
:tag "py-dedicated-process-p"
:group 'python-mode)
(defvar py-shell--font-lock-buffer "*PSFLB*"
"May contain the ‘py-buffer-name’ currently fontified." )
(defvar py-return-result-p nil
"Internally used.
When non-nil, return resulting string of `py-execute-...'.
Imports will use it with nil.
Default is nil")
(defun py-toggle-py-return-result-p ()
"Toggle value of ‘py-return-result-p’."
(interactive)
(setq py-return-result-p (not py-return-result-p))
(when (called-interactively-p 'interactive) (message "py-return-result-p: %s" py-return-result-p)))
(defcustom py--execute-use-temp-file-p nil
"Assume execution at a remote machine.
where write-access is not given."
:type 'boolean
:tag "py--execute-use-temp-file-p"
:group 'python-mode)
(defvar py--match-paren-forward-p nil
"Internally used by ‘py-match-paren’.")
(defvar py-new-session-p t
"Internally used. See lp:1393882.
Restart ‘py-shell’ once with new Emacs/‘python-mode’.")
(defcustom py-electric-close-active-p nil
"Close completion buffer if no longer needed.
Works around a bug in ‘choose-completion’.
Default is nil"
:type 'boolean
:tag "py-electric-close-active-p"
:group 'python-mode)
(defcustom py-hide-show-minor-mode-p nil
"If hide-show minor-mode should be on, default is nil."
:type 'boolean
:tag "py-hide-show-minor-mode-p"
:group 'python-mode)
(defcustom py-do-completion-p t
"Permits disabling all python-mode native completion.
Default is ‘t’.
See #144, how to disable process spawn for autocompletion"
:type 'boolean
:tag "py-do-completion-p"
:group 'python-mode)
(defcustom py-load-skeletons-p nil
"If skeleton definitions should be loaded, default is nil.
If non-nil and variable ‘abbrev-mode’ on, block-skeletons will inserted.
Pressing \"if<SPACE>\" for example will prompt for the if-condition."
:type 'boolean
:tag "py-load-skeletons-p"
:group 'python-mode)
(defcustom py-if-name-main-permission-p t
"Allow execution of code inside blocks started.
by \"if __name__== '__main__':\".
Default is non-nil"
:type 'boolean
:tag "py-if-name-main-permission-p"
:group 'python-mode)
(defcustom py-use-font-lock-doc-face-p nil
"If documention string inside of def or class get ‘font-lock-doc-face’.
‘font-lock-doc-face’ inherits ‘font-lock-string-face’.
Call \\<emacs-lisp-mode-map> \\[customize-face] in order to have a effect."
:type 'boolean
:tag "py-use-font-lock-doc-face-p"
:group 'python-mode)
(defcustom py-empty-comment-line-separates-paragraph-p t
"Consider paragraph start/end lines with nothing inside but comment sign.
Default is non-nil"
:type 'boolean
:tag "py-empty-comment-line-separates-paragraph-p"
:group 'python-mode)
(defcustom py-indent-honors-inline-comment nil
"If non-nil, indents to column of inlined comment start.
Default is nil."
:type 'boolean
:tag "py-indent-honors-inline-comment"
:group 'python-mode)
(defcustom py-auto-fill-mode nil
"If ‘python-mode’ should set ‘fill-column’.
according to values
in ‘py-comment-fill-column’ and ‘py-docstring-fill-column’.
Default is nil"
:type 'boolean
:tag "py-auto-fill-mode"
:group 'python-mode)
(defcustom py-error-markup-delay 4
"Seconds error's are highlighted in exception buffer."
:type 'integer
:tag "py-error-markup-delay"
:group 'python-mode)
(defcustom py-fast-completion-delay 0.1
"Used by ‘py-fast-send-string’."
:type 'float
:tag "py-fast-completion-delay"
:group 'python-mode)
(defcustom py-new-shell-delay
(if (eq system-type 'windows-nt)
2.0
1.0)
"If a new comint buffer is connected to Python.
Commands like completion might need some delay."
:type 'float
:tag "py-new-shell-delay"
:group 'python-mode)
(defcustom py-autofill-timer-delay 1
"Delay when idle."
:type 'integer
:tag "py-autofill-timer-delay"
:group 'python-mode)
(defcustom py-docstring-fill-column 72
"Value of ‘fill-column’ to use when filling a docstring.
Any non-integer value means do not use a different value of
‘fill-column’ when filling docstrings."
:type '(choice (integer)
(const :tag "Use the current ‘fill-column’" t))
:tag "py-docstring-fill-column"
:group 'python-mode)
(defcustom py-comment-fill-column 79
"Value of ‘fill-column’ to use when filling a comment.
Any non-integer value means do not use a different value of
‘fill-column’ when filling docstrings."
:type '(choice (integer)
(const :tag "Use the current ‘fill-column’" t))
:tag "py-comment-fill-column"
:group 'python-mode)
(defcustom py-fontify-shell-buffer-p nil
"If code in Python shell should be highlighted as in script buffer.
Default is nil.
If t, related vars like ‘comment-start’ will be set too.
Seems convenient when playing with stuff in IPython shell
Might not be TRT when a lot of output arrives"
:type 'boolean
:tag "py-fontify-shell-buffer-p"
:group 'python-mode)
(defvar py-modeline-display ""
"Internally used.")
(defcustom py-modeline-display-full-path-p nil
"If the full PATH/TO/PYTHON be in modeline.
Default is nil. Note: when ‘py-python-command’ is
specified with path, it's shown as an acronym in
‘buffer-name’ already."
:type 'boolean
:tag "py-modeline-display-full-path-p"
:group 'python-mode)
(defcustom py-modeline-acronym-display-home-p nil
"If the modeline acronym should contain chars indicating the home-directory.
Default is nil"
:type 'boolean
:tag "py-modeline-acronym-display-home-p"
:group 'python-mode)
(defun py-autopair-check ()
"Check, if ‘autopair-mode’ is available.
Give some hints, if not."
(interactive)
(if (featurep 'autopair)
't
(progn
(message "py-autopair-check: %s" "Don't see autopair.el. Make sure, it's installed. If not, maybe see source: URL: http://autopair.googlecode.com")
nil)))
(defvar highlight-indent-active nil)
(defvar autopair-mode nil)
(defvar-local py--editbeg nil
"Internally used by ‘py-edit-docstring’ and others")
(defvar-local py--editend nil
"Internally used by ‘py-edit-docstring’ and others")
(defvar py--oldbuf nil
"Internally used by ‘py-edit-docstring’.")
(defvar py-edit-buffer "Edit docstring"
"Name of the temporary buffer to use when editing.")
(defvar py--edit-register nil)
(defvar py-result nil
"Internally used. May store result from Python process.
See var ‘py-return-result-p’ and command ‘py-toggle-py-return-result-p’")
(defvar py-error nil
"Takes the error-messages from Python process.")
(defvar py-python-completions "*Python Completions*"
"Buffer name for Python-shell completions, internally used.")
(defvar py-ipython-completions "*IPython Completions*"
"Buffer name for IPython-shell completions, internally used.")
(defcustom py-timer-close-completions-p t
"If ‘py-timer-close-completion-buffer’ should run, default is non-nil."
:type 'boolean
:tag "py-timer-close-completions-p"
:group 'python-mode)
(defcustom py-autopair-mode nil
"If ‘python-mode’ calls (autopair-mode-on)
Default is nil
Load ‘autopair-mode’ written by Joao Tavora <joaotavora [at] gmail.com>
URL: http://autopair.googlecode.com"
:type 'boolean
:tag "py-autopair-mode"
:group 'python-mode)
(defcustom py-indent-no-completion-p nil
"If completion function should insert a TAB when no completion found.
Default is nil"
:type 'boolean
:tag "py-indent-no-completion-p"
:group 'python-mode)
(defcustom py-company-pycomplete-p nil
"Load company-pycomplete stuff. Default is nil."
:type 'boolean
:tag "py-company-pycomplete-p"
:group 'python-mode)
(defvar py-last-position nil
"Used by ‘py-help-at-point’.
Avoid repeated call at identic pos.")
(defvar py-auto-completion-mode-p nil
"Internally used by ‘py-auto-completion-mode’.")
(defvar py-complete-last-modified nil
"Internally used by ‘py-auto-completion-mode’.")
(defvar py--auto-complete-timer nil
"Internally used by ‘py-auto-completion-mode’.")
(defvar py-auto-completion-buffer nil
"Internally used by ‘py-auto-completion-mode’.")
(defvar py--auto-complete-timer-delay 1
"Seconds Emacs must be idle to trigger auto-completion.
See ‘py-auto-completion-mode’")
(defcustom py-auto-complete-p nil
"Run python-mode's built-in auto-completion via ‘py-complete-function’.
Default is nil."
:type 'boolean
:tag "py-auto-complete-p"
:group 'python-mode)
(defcustom py-tab-shifts-region-p nil
"If t, TAB will indent/cycle the region, not just the current line.
Default is nil
See also ‘py-tab-indents-region-p’"
:type 'boolean
:tag "py-tab-shifts-region-p"
:group 'python-mode)
(defcustom py-tab-indents-region-p nil
"When t and first TAB doesn't shift, ‘indent-region’ is called.
Default is nil
See also ‘py-tab-shifts-region-p’"
:type 'boolean
:tag "py-tab-indents-region-p"
:group 'python-mode)
(defcustom py-block-comment-prefix-p t
"If py-comment inserts ‘py-block-comment-prefix’.
Default is t"
:type 'boolean
:tag "py-block-comment-prefix-p"
:group 'python-mode)
(defcustom py-org-cycle-p nil
"When non-nil, command ‘org-cycle’ is available at shift-TAB, <backtab>.
Default is nil."
:type 'boolean
:tag "py-org-cycle-p"
:group 'python-mode)
(defcustom py-set-complete-keymap-p nil
"If ‘py-complete-initialize’.
Sets up enviroment for Pymacs based py-complete.
Should load it's keys into ‘python-mode-map’
Default is nil.
See also resp. edit ‘py-complete-set-keymap’"
:type 'boolean
:tag "py-set-complete-keymap-p"
:group 'python-mode)
(defcustom py-outline-minor-mode-p t
"If outline minor-mode should be on, default is t."
:type 'boolean
:tag "py-outline-minor-mode-p"
:group 'python-mode)
(defvar py-guess-py-install-directory-p nil
"If in cases, ‘py-install-directory’ isn't set, ‘py-set-load-path’ guess it.")
(defcustom py-guess-py-install-directory-p nil
"If in cases, ‘py-install-directory’ isn't set, ‘py-set-load-path’ guesses it."
:type 'boolean
:tag "py-guess-py-install-directory-p"
:group 'python-mode)
(defcustom py-load-pymacs-p nil
"If Pymacs related stuff should be loaded. Default is nil.
Pymacs has been written by François Pinard and many others.
See original source: http://pymacs.progiciels-bpi.ca"
:type 'boolean
:tag "py-load-pymacs-p"
:group 'python-mode)
(defcustom py-verbose-p nil
"If functions should report results.
Default is nil."
:type 'boolean
:tag "py-verbose-p"
:group 'python-mode)
(defcustom py-sexp-function nil
"Called instead of ‘forward-sexp’, ‘backward-sexp’.
Default is nil."
:type '(choice
(const :tag "default" nil)
(const :tag "py-forward-partial-expression" py-forward-partial-expression)
(const :tag "py-forward-expression" py-forward-expression))
:tag "py-sexp-function"
:group 'python-mode)
(defcustom py-close-provides-newline t
"If a newline is inserted, when line after block isn't empty.
Default is non-nil.
When non-nil, ‘py-forward-def’ and related will work faster"
:type 'boolean
:tag "py-close-provides-newline"
:group 'python-mode)
(defcustom py-dedent-keep-relative-column t
"If point should follow dedent or kind of electric move to end of line.
Default is t - keep relative position."
:type 'boolean
:tag "py-dedent-keep-relative-column"
:group 'python-mode)
(defcustom py-indent-list-style 'line-up-with-first-element
"Sets the basic indentation style of lists.
The term ‘list’ here is seen from Emacs Lisp editing purpose.
A list symbolic expression means everything delimited by
brackets, parentheses or braces.
Setting here might be ignored in case of canonical indent.
‘line-up-with-first-element’ indents to 1+ column
of opening delimiter
def foo (a,
b):
but ‘one-level-to-beginning-of-statement’ in case of EOL at list-start
def foo (
a,
b):
‘one-level-to-beginning-of-statement’ adds
‘py-indent-offset’ to beginning
def long_function_name(
var_one, var_two, var_three,
var_four):
print(var_one)
‘one-level-from-first-element’ adds ‘py-indent-offset’ from first element
def foo():
if (foo &&
baz):
bar()"
:type '(choice
(const :tag "line-up-with-first-element" line-up-with-first-element)
(const :tag "one-level-to-beginning-of-statement" one-level-to-beginning-of-statement)
(const :tag "one-level-from-first-element" one-level-from-first-element)
)
:tag "py-indent-list-style"
:group 'python-mode)
(make-variable-buffer-local 'py-indent-list-style)
(defcustom py-closing-list-dedents-bos nil
"When non-nil, indent lists closing delimiter like start-column.
It will be lined up under the first character of
the line that starts the multi-line construct, as in:
my_list = [
1, 2, 3,
4, 5, 6
]
result = some_function_that_takes_arguments(
\\='a\\=', \\='b\\=', \\='c\\=',
\\='d\\=', \\='e\\=', \\='f\\='
)
Default is nil, i.e.
my_list = [
1, 2, 3,
4, 5, 6
]
result = some_function_that_takes_arguments(
\\='a\\=', \\='b\\=', \\='c\\=',
\\='d\\=', \\='e\\=', \\='f\\='
)
Examples from PEP8
URL: https://www.python.org/dev/peps/pep-0008/#indentation"
:type 'boolean
:tag "py-closing-list-dedents-bos"
:group 'python-mode)
(defvar py-imenu-max-items 99)
(defcustom py-imenu-max-items 99
"Python-mode specific ‘imenu-max-items’."
:type 'number
:tag "py-imenu-max-items"
:group 'python-mode)
(defcustom py-closing-list-space 1
"Number of chars, closing parenthesis outdent from opening, default is 1."
:type 'number
:tag "py-closing-list-space"
:group 'python-mode)
(defcustom py-max-specpdl-size 99
"Heuristic exit.
e
Limiting number of recursive calls by ‘py-forward-statement’ and related.
Default is ‘max-specpdl-size’.
This threshold is just an approximation. It might set far higher maybe.
See lp:1235375. In case code is not to navigate due to errors,
command ‘which-function-mode’ and others might make Emacs hang.
Rather exit than."
:type 'number
:tag "py-max-specpdl-size"
:group 'python-mode)
(defcustom py-closing-list-keeps-space nil
"If non-nil, closing parenthesis dedents onto column of opening.
Adds ‘py-closing-list-space’.
Default is nil."
:type 'boolean
:tag "py-closing-list-keeps-space"
:group 'python-mode)
(defcustom py-electric-colon-active-p nil
"‘py-electric-colon’ feature.
Default is nil. See lp:837065 for discussions.
See also ‘py-electric-colon-bobl-only’"
:type 'boolean
:tag "py-electric-colon-active-p"
:group 'python-mode)
(defcustom py-electric-colon-bobl-only t
"When inserting a colon, do not indent lines unless at beginning of block.
See lp:1207405 resp. ‘py-electric-colon-active-p’"
:type 'boolean
:tag "py-electric-colon-bobl-only"
:group 'python-mode)
(defcustom py-electric-yank-active-p nil
"When non-nil, ‘yank’ will be followed by an ‘indent-according-to-mode’.
Default is nil"
:type 'boolean
:tag "py-electric-yank-active-p"
:group 'python-mode)
(defcustom py-electric-colon-greedy-p nil
"If ‘py-electric-colon’ should indent to the outmost reasonable level.
If nil, default, it will not move from at any reasonable level."
:type 'boolean
:tag "py-electric-colon-greedy-p"
:group 'python-mode)
(defcustom py-electric-colon-newline-and-indent-p nil
"If non-nil, ‘py-electric-colon’ will call ‘newline-and-indent’.
Default is nil."
:type 'boolean
:tag "py-electric-colon-newline-and-indent-p"
:group 'python-mode)
(defcustom py-electric-comment-p nil
"If \"#\" should call ‘py-electric-comment’. Default is nil."
:type 'boolean