• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /macosx-10.10.1/emacs-93/emacs/lisp/progmodes/

Lines Matching +defs:indent +defs:to

23 ;; along with GNU Emacs; see the file COPYING.  If not, write to the
33 ;; assignment, unlike this code, and seems not to be well-maintained
45 ;; not specific to Python, and I've installed a minor mode to do the
47 ;; feature, `c-subword-mode' which is intended to have a similar
61 ;; bindings are changed to obey Emacs conventions.
83 (add-to-list 'interpreter-mode-alist '("jython" . jython-mode))
85 (add-to-list 'interpreter-mode-alist '("python" . python-mode))
87 (add-to-list 'auto-mode-alist '("\\.py\\'" . python-mode))
102 ;; Not real keywords, but close enough to be fontified as such
136 ;; Given a triple quote, we have to check the context to know
138 ;; quoted anyhow, and should be ignored. (For that we need to do
139 ;; the same job as `syntax-ppss' to be correct and it seems to be OK
140 ;; to use it here despite initial worries.) We also have to sort
141 ;; out a possible prefix -- well, we don't _have_ to, but I think it
149 ;; Fixme: """""" goes wrong (due to syntax-ppss not getting the string
162 (eval-when-compile (string-to-syntax "|"))))))
169 (eval-when-compile (string-to-syntax "|"))))
217 (define-key map "\C-c\C-z" 'python-switch-to-python)
238 :help "Go to start of innermost definition around point"]
240 :help "Go to end of innermost definition around point"]
242 :help "Go to start of innermost definition around point"]
244 :help "Go to end of innermost definition around point"]
263 ["Switch to interpreter" python-switch-to-python
264 :help "Switch to inferior Python buffer"]
279 ;; region, at least. (Shouldn't be specific to Python, obviously.)
280 ;; eric has items including: (un)indent, (un)comment, restart script,
285 ;; Give punctuation syntax to ASCII that normally has symbol
287 (let ((symbol (string-to-syntax "_"))
307 ;; We don't need to save the match data.
359 (back-to-indentation)
369 "Go to beginning of string around point.
377 BOS non-nil means point is known to be at beginning of statement."
391 (back-to-indentation)
398 (back-to-indentation)
402 ;; Ensure there's a previous statement and move to it.
411 (defcustom python-indent 4
413 See also `\\[python-guess-indent]'"
416 (put 'python-indent 'safe-local-variable 'integerp)
418 (defcustom python-guess-indent t
419 "Non-nil means Python mode guesses `python-indent' for the buffer."
423 (defcustom python-indent-string-contents t
424 "Non-nil means indent contents of multi-line strings together.
425 This means indent them the same as the preceding non-blank line.
428 This only applies to `doc' strings, i.e. those that form statements;
435 "Non-nil means indent relative to preceding comment line.
437 followed by space. This doesn't apply to comment lines, which
449 (defun python-guess-indent ()
451 Set `python-indent' locally to the value guessed."
457 (let (done indent)
468 (setq indent (- (current-indentation) initial)))
469 (if (and indent (>= indent 2) (<= indent 8)) ; sanity check
472 (when (/= indent (default-value 'python-indent))
473 (set (make-local-variable 'python-indent) indent)
474 (unless (= tab-width python-indent)
475 (setq indent-tabs-mode nil)))
476 indent)))))
480 (defvar python-indent-list nil
483 (defvar python-indent-list-length nil
486 (defvar python-indent-index nil
491 (setq python-indent-list nil
492 python-indent-list-length 1)
499 (if (not python-indent-string-contents)
501 ;; Only respect `python-indent-string-contents' in doc
535 (+ python-indent (current-column))
537 ;; Otherwise indent relative to statement start, one
541 (+ (current-indentation) (* (car syntax) python-indent))))
553 python-indent
579 ;; Prefer to indent comments with an immediately-following
584 (when (and (> python-indent-list-length 1)
588 (let ((elt (assq (current-indentation) python-indent-list)))
589 (setq python-indent-list
590 (nconc (delete elt python-indent-list)
592 (caar (last python-indent-list)))))))
596 ;; These don't need to be buffer-local since they're only relevant
603 (back-to-indentation)
622 (back-to-indentation)
627 It is assumed not to be a continuation line or in a multi-line string.
634 levels indent)
640 (setq indent (current-indentation))
646 (setq indent (+ python-indent indent)))))
647 (push (cons indent initial) levels))
669 ;; Not sensible to indent to the same level as
681 (setq python-indent-list levels
682 python-indent-list-length (length python-indent-list))))))
684 ;; This is basically what `python-indent-line' would be if we didn't
686 (defun python-indent-line-1 (&optional leave)
687 "Subroutine of `python-indent-line'.
695 (and leave python-indent-list
696 (assq (current-indentation) python-indent-list)))
698 (back-to-indentation))
701 (indent-to target)
705 (defun python-indent-line ()
707 When invoked via `indent-for-tab-command', cycle through possible
709 different from `indent-for-tab-command', i.e. successive TABs do
712 (if (and (eq this-command 'indent-for-tab-command)
714 (if (= 1 python-indent-list-length)
716 (progn (setq python-indent-index
717 (% (1+ python-indent-index) python-indent-list-length))
720 (indent-to (car (nth python-indent-index python-indent-list)))
722 (let ((text (cdr (nth python-indent-index
723 python-indent-list))))
726 (python-indent-line-1)
727 (setq python-indent-index (1- python-indent-list-length))))
729 (defun python-indent-region (start end)
730 "`indent-region-function' for Python.
731 Leaves validly-indented lines alone, i.e. doesn't indent to
740 (python-indent-line-1 t))
746 or a blank line indented to where it would close a block."
797 ;; Go to start of current block and check whether it's at top
814 ;; If we got to the start of buffer, look forward for
828 ;; skips to a definition we're not in:
839 "Go to start of current statement.
853 (back-to-indentation))
878 "Go to the end of the current statement and return point.
880 multi-line statement we need to skip over the continuation lines.
881 On a comment line, go to end of line."
891 ;; Go to start of string and skip it.
904 "Go to start of previous statement.
906 Return count of statements left to move."
919 "Go to start of next statement.
921 Return count of statements left to move."
935 "Go to start of current block.
966 ;; Move to beginning to save effort in case
976 "Go to end of current block.
1016 definition; it has a space prepended to the name so that it sorts
1025 ;; what's going on, but it must be something to do with timers in
1031 (let (index-alist) ; accumulated value to return
1043 (narrow-to-defun)
1081 (python-indent-line))) ; OK, do it
1096 (let ((indent 0)
1102 (setq indent (max indent (car x)))))
1103 (setq initial (cdr (assq indent indents)))
1107 (indent-to indent))))
1114 "Command used to check a Python file."
1147 "Shell command to run Python interpreter.
1155 "Shell command to run Jython interpreter.
1161 "Actual command used to run Python.
1169 Commands that send text from source buffers to Python processes have
1170 to choose a process to send to. This is determined by buffer-local
1173 and commands that send to the Python process will start a new process.
1176 value of `python-buffer' to be the new process's buffer and sets the
1181 Use \\[python-set-proc] to set the default value from a buffer with a
1186 ;; FIXME: maybe these should move to compilation-error-regexp-alist-alist.
1188 ;; these are specific to the inferior buffer. -- fx
1203 ;; Note that we _can_ still use these commands which send to the
1231 You can send text to the inferior Python process from other buffers
1233 * \\[python-switch-to-python] switches the current buffer to the Python
1235 * \\[python-send-region] sends the current region to the Python process.
1236 * \\[python-send-region-and-go] switches to the Python process buffer
1248 ;; (and we need to match things like `>>> ... >>> '):
1267 (defun python-args-to-list (string)
1272 (python-args-to-list (substring string (+ 1 where)))))
1274 (if pos (python-args-to-list (substring string pos))))))))
1316 ;; The need for this seems to be system-dependent:
1336 CMD is the Python command to run. NOSHOW non-nil means don't show the
1340 switch to that buffer. Interactively, a prefix arg allows you to edit
1342 will be added to this as appropriate. A new process is started if:
1343 one isn't running attached to `python-buffer', or interactively the
1361 (append (python-args-to-list cmd)
1364 (process-environment ; to import emacs.py
1380 ;; to put it in a module.
1388 (unless noshow (pop-to-buffer python-buffer t)))
1392 ;; the prompt is unexpected. Actually, it needs to be `>>> ', not
1394 ;; be the place to check it, e.g. we might actually want to send
1407 ;; No idea what this is for but it breaks the call to
1416 "Send the region to the inferior Python process."
1421 ;; function to remove the temporary file when it has been evaluated
1424 ;; tracebacks not to mention the frame of the function itself.
1427 ;; the reference to the temporary file to the source.
1429 ;; Fixme: Write a `coding' header to the temp file if the region is
1446 ;; Tell compile.el to redirect error locations in file `f' to
1447 ;; positions past marker `orig-start'. It has to be done *after*
1448 ;; `python-send-command''s call to `compilation-forget-errors'.
1460 ;; as to make sure we terminate the multiline instruction.
1464 "Send the current buffer to the inferior Python process."
1468 ;; Fixme: Try to define the function or class within the relevant
1471 "Send the current defun (class or method) to the inferior Python process."
1476 (defun python-switch-to-python (eob-p)
1477 "Switch to the Python process buffer, maybe starting new process.
1480 (pop-to-buffer (process-buffer (python-proc)) t) ;Runs python if needed.
1486 "Send the region to the inferior Python process.
1487 Then switch to the process buffer."
1490 (python-switch-to-python t))
1493 "Used to determine if a buffer contains Python source code.
1496 value to determine defaults."
1515 (comint-check-source file-name) ; Check to see if buffer needs saving.
1541 "Set the default value of `python-buffer' to correspond to this buffer.
1543 default (global) value to that. The associated Python process is
1562 (defvar view-return-to-alist)
1568 ;; bound to C-h S? [Probably not, since info-look may work in cases
1581 ;; Note that we do this in the inferior process, not a separate one, to
1598 (setq view-return-to-alist
1600 (with-output-to-temp-buffer (help-buffer)
1606 (comint-redirect-send-command-to-process (format "emacs.ehelp(%S, %s)"
1610 (add-to-list 'debug-ignored-errors "^No symbol")
1613 "Send STRING to inferior Python (if any) and return result.
1633 ;; This is run from timers, so inhibit-quit tends to be set.
1639 ;; Try moving to symbol before enclosing parens.
1660 (let* ((version (let ((s (shell-command-to-string (concat python-command
1679 ;; Fixme: Can this reasonably be made specific to indices with
1713 actually punts to `jython-mode'."
1718 ;; mode. See logic there to break out of the recursion.
1720 "Invoke `jython-mode' if the buffer appears to contain Jython code.
1756 ;; don't allow us to delimit the last paragraph in a multi-line
1757 ;; string properly, so narrow to the string and then fill around
1780 (narrow-to-region start end)
1790 "Shift lines in region COUNT (the prefix arg) columns to the left.
1791 COUNT defaults to `python-indent'. If region isn't active, just shift
1800 (setq count python-indent))
1809 (indent-rigidly start end (- count)))))
1811 (add-to-list 'debug-ignored-errors "^Can't shift all lines enough")
1814 "Shift lines in region COUNT (the prefix arg) columns to the right.
1815 COUNT defaults to `python-indent'. If region isn't active, just shift
1823 (setq count python-indent))
1824 (indent-rigidly start end count))
1828 The level is the number of `python-indent' steps of indentation
1830 (1+ (/ (current-indentation) python-indent)))
1837 ;; get to zero indentation, accumulating the defined names.
1860 ;; Fixme: Provide a find-function-like command to find source of a
1871 ;; Fixme: Should font-lock try to run this when it deals with an import?
1873 ;; statement is being edited, and is more likely to end up with
1875 ;; However, what we should do is to trundle up the block tree from point
1876 ;; to extract imports that appear to be in scope, and add those.
1891 ;; This is probably best left out since you're unlikely to need the
1911 ;; running. Presumably a timing issue with i/o to the process.
1915 Uses `python-imports' to load modules against which to complete."
1969 (with-output-to-temp-buffer "*Completions*"
1997 "Function for `ffap-alist' to return path to MODULE."
2008 This happens when pressing \"if<SPACE>\", for example, to prompt for
2019 The default contents correspond to the elements of `python-skeletons'.")
2023 ;; Define a user-level skeleton and add it to `python-skeletons' and
2029 (add-to-list 'python-skeletons ',(cons name function))
2035 (put 'def-python-skeleton 'lisp-indent-function 2)
2113 "Default template to expand by `python-expand-template'.
2120 (list (completing-read (format "Template to expand (default %s): "
2160 :help "Interface to navigation and refactoring tool"
2163 :help "Find references to name at point in compilation buffer"]
2179 ;; Fixme: Should check for anything to revert.
2189 ;; Stuff to allow expanding abbrevs with non-word constituents.
2211 See also `jython-mode', which is actually invoked if the buffer appears to
2223 deletes a level of indentation to close the current block; otherwise it
2224 deletes a character backward. TAB indents the current line relative to
2235 and this is added to the Hippie Expand functions locally if
2254 (set (make-local-variable 'indent-line-function) #'python-indent-line)
2255 (set (make-local-variable 'indent-region-function) #'python-indent-region)
2278 ;; Fixme: should be in hideshow. This seems to be of limited use
2280 ;; doesn't seem to work properly.
2281 (add-to-list 'hs-special-modes-alist
2288 '((< '(backward-delete-char-untabify (min python-indent
2297 (when python-guess-indent (python-guess-indent))
2298 ;; Let's make it harder for the user to shoot himself in the foot.
2299 (unless (= tab-width python-indent)
2300 (setq indent-tabs-mode nil))
2311 (set (make-local-variable 'indent-tabs-mode) nil)))