Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
0ec5c5dc
Kaydet (Commit)
0ec5c5dc
authored
Nis 25, 1994
tarafından
Guido van Rossum
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Improvements from Tim after some complaints...
üst
a143e90c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
83 additions
and
23 deletions
+83
-23
python-mode-old.el
Misc/python-mode-old.el
+83
-23
No files found.
Misc/python-mode-old.el
Dosyayı görüntüle @
0ec5c5dc
;;; Major mode for editing Python programs, version 1.08a
x
;;; Major mode for editing Python programs, version 1.08a
y
;; by: Tim Peters <tim@ksr.com>
;; by: Tim Peters <tim@ksr.com>
;; after an original idea by: Michael A. Guravage
;; after an original idea by: Michael A. Guravage
;;
;;
...
@@ -509,25 +509,74 @@ the new line indented."
...
@@ -509,25 +509,74 @@ the new line indented."
(
cond
(
cond
;; are we on a continuation line?
;; are we on a continuation line?
(
(
py-continuation-line-p
)
(
(
py-continuation-line-p
)
(
let
(
(
open-bracket-pos
(
py-nesting-level
))
)
(
let
(
(
startpos
(
point
))
(
open-bracket-pos
(
py-nesting-level
))
endpos
searching
found
)
(
if
open-bracket-pos
(
if
open-bracket-pos
;; line up with first real character (not whitespace or
;; comment hash) after open bracket; if none, to one
;; column beyond the open bracket
(
progn
(
progn
(
goto-char
(
1+
open-bracket-pos
))
; just beyond bracket
;; if preceding line in same structure, presumably the
(
and
(
looking-at
"[ \t]*[^ \t\n#]"
)
;; user already has an indentation they like for this
(
goto-char
(
1-
(
match-end
0
))))
;; structure, so just copy it
(
current-column
))
(
forward-line
-1
)
(
while
(
looking-at
"[ \t]*[#\n]"
)
(
forward-line
-1
))
; ignore noise lines
(
if
(
eq
open-bracket-pos
(
py-nesting-level
))
(
current-indentation
)
;; else copy the indentation of the first item (if
;; any) in this structure
(
goto-char
startpos
)
(
condition-case
nil
(
progn
(
backward-list
)
(
setq
found
t
))
(
error
nil
))
; no preceding item
(
goto-char
(
1+
open-bracket-pos
))
; just beyond bracket
(
if
found
(
progn
(
while
(
looking-at
"[ \t]*[#\n\\\\]"
)
(
forward-line
1
))
(
skip-chars-forward
" \t"
)
(
current-column
))
;; else to first real character (not whitespace or
;; comment hash) after open bracket; if none, to
;; 1 beyond the open bracket
(
and
(
looking-at
"[ \t]*[^ \t\n#]"
)
(
goto-char
(
1-
(
match-end
0
))))
(
current-column
))))
;; else on backslash continuation line
;; else on backslash continuation line
(
forward-line
-1
)
(
forward-line
-1
)
(
if
(
py-continuation-line-p
)
; on at least 3rd line in block
(
if
(
py-continuation-line-p
)
; on at least 3rd line in block
(
current-indentation
)
; so just continue the pattern
(
current-indentation
)
; so just continue the pattern
;; else started on 2nd line in block, so indent more;
;; else started on 2nd line in block, so indent more.
;; skip first chunk of non-whitespace characters on base
;; if base line is an assignment with a start on a RHS,
;; line, + 1 more column
;; indent to 2 beyond the leftmost "="; else skip first
;; chunk of non-whitespace characters on base line, + 1 more
;; column
(
end-of-line
)
(
setq
endpos
(
point
)
searching
t
)
(
back-to-indentation
)
(
back-to-indentation
)
(
skip-chars-forward
"^ \t\n"
)
(
setq
startpos
(
point
))
;; look at all "=" from left to right, stopping at first
;; one not nested in a list or string
(
while
searching
(
skip-chars-forward
"^="
endpos
)
(
if
(
=
(
point
)
endpos
)
(
setq
searching
nil
)
(
forward-char
1
)
(
setq
state
(
parse-partial-sexp
startpos
(
point
)))
(
if
(
and
(
zerop
(
car
state
))
; not in a bracket
(
null
(
nth
3
state
)))
; & not in a string
(
progn
(
setq
searching
nil
)
; done searching in any case
(
setq
found
(
not
(
or
(
eq
(
char-after
(
point
))
?=
)
(
memq
(
char-after
(
-
(
point
)
2
))
'
(
?<
?>
?!
)))))))))
(
if
(
or
(
not
found
)
; not an assignment
(
looking-at
"[ \t]*\\\\"
))
; <=><spaces><backslash>
(
progn
(
goto-char
startpos
)
(
skip-chars-forward
"^ \t\n"
)))
(
1+
(
current-column
))))))
(
1+
(
current-column
))))))
;; not on a continuation line
;; not on a continuation line
...
@@ -1263,18 +1312,29 @@ statement has `:' as its last significant (non-whitespace and non-
...
@@ -1263,18 +1312,29 @@ statement has `:' as its last significant (non-whitespace and non-
comment) character. If the suggested indentation is too much, use
comment) character. If the suggested indentation is too much, use
\\[py-delete-char] to reduce it.
\\[py-delete-char] to reduce it.
Continuation lines are given extra indentation. If a line is a
Continuation lines are given extra indentation. If you don't like the
continuation line by virtue of being in an unclosed paren/bracket/
suggested indentation, change it to something you do like, and Python-
brace structure, it's indented to line up with the first non-whitespace
mode will strive to indent later lines of the statement in the same way.
and non-comment character following the opening paren/bracket/brace
of the smallest such enclosing structure. If no such character exists,
If a line is a continuation line by virtue of being in an unclosed
it's indented to one column beyond the opening paren/bracket/brace.
paren/bracket/brace structure (`list', for short), the suggested
indentation depends on whether the current line will contain the first
item in the list. If it is the first item, it's indented to line up with
the first non-whitespace and non-comment character following the list's
opening bracket; if no such character exists, it's indented to one column
beyond the opening bracket. If you don't like that, change it by hand.
The remaining items in the list will mimic whatever indentation you gave
to the first item.
If a line is a continuation line because the line preceding it ends with
If a line is a continuation line because the line preceding it ends with
a backslash, the third and following lines of the continuation block
a backslash, the third and following lines of the statement inherit their
inherit their indentation from the line preceding them, while the second
indentation from the line preceding them. The indentation of the second
line in the block is indented to one column beyond the first chunk of
line in the statement depends on the form of the first (base) line: if
non-whitespace characters in the block's initial line.
the base line is an assignment statement with anything more interesting
than the backslash following the leftmost assigning `=', the second line
is indented two columns beyond that `='. Else it's indented to two
columns beyond the leftmost solid chunk of non-whitespace characters on
the base line.
Warning: indent-region should not normally be used! It calls \\[indent-for-tab-command]
Warning: indent-region should not normally be used! It calls \\[indent-for-tab-command]
repeatedly, and as explained above, \\[indent-for-tab-command] can't guess the block
repeatedly, and as explained above, \\[indent-for-tab-command] can't guess the block
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment