• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /macosx-10.9.5/emacs-92/emacs/lisp/progmodes/

Lines Matching +defs:comment +defs:indent +defs:function

37 ;; it more correct with arbitrary string and comment contents.
109 (1 font-lock-keyword-face) (2 font-lock-function-name-face))
177 ;; (defun python-font-lock-syntactic-face-function (state)
178 ;; "`font-lock-syntactic-face-function' for Python mode.
179 ;; Returns the string or comment face as usual, with side effect of putting
180 ;; a `syntax-table' property on the inside of the string or comment which is
193 ;; 'font-lock-comment-face))
280 ;; eric has items including: (un)indent, (un)comment, restart script,
305 (defsubst python-in-string/comment ()
306 "Return non-nil if point is in a Python literal (a comment or string)."
323 ;; If we're in a comment (including on the trailing
324 ;; newline), forward-comment doesn't move backwards out
332 (forward-comment arg))))
335 "Non-nil if preceding line ends with backslash that is not in a comment."
354 (defun python-comment-line-p ()
355 "Return non-nil iff current line has only a comment."
358 (when (eq 'comment (syntax-ppss-context (syntax-ppss)))
360 (looking-at (rx (or (syntax comment-start) line-end))))))
387 The criteria are that the line isn't a comment or in string and
401 (not (python-in-string/comment))
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.
434 (defcustom python-honour-comment-indentation nil
435 "Non-nil means indent relative to preceding comment line.
436 Only do this for comments where the leading comment character is
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)
460 (or (syntax comment-start)
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
557 ((looking-at (rx (0+ space) (syntax comment-start)
558 (not (any " \t\n")))) ; non-indentable comment
560 (t (if python-honour-comment-indentation
565 ;; not at comment start
566 ((not (forward-comment -1))
569 ;; trailing comment
573 ;; indentable comment like python-mode.el
574 ((and (looking-at (rx (syntax comment-start)
579 ;; Prefer to indent comments with an immediately-following
584 (when (and (> python-indent-list-length 1)
585 (python-comment-line-p))
587 (unless (python-comment-line-p)
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)))))))
600 "Text of line following indentation and ignoring any trailing comment."
607 (forward-comment -1)
634 levels indent)
640 (setq indent (current-indentation))
646 (setq indent (+ python-indent indent)))))
647 (push (cons indent initial) levels))
648 ;; Only one possibility for comment line immediately following
651 (when (python-comment-line-p)
653 (if (python-comment-line-p)
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)))
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))
747 (and (not (python-comment-line-p))
757 ;; Fixme: Define {for,back}ward-sexp-function? Maybe skip units like
761 "`beginning-of-defun-function' for Python.
769 (if (python-comment-line-p)
772 ;; Treat bol at beginning of function as outside function so
784 ;; last internal function followed by first
789 (not (python-in-string/comment)))
793 "`end-of-defun-function' for Python.
800 (when (python-comment-line-p)
802 (forward-comment most-positive-fixnum))
808 (python-in-string/comment))) ; just loop
819 (python-in-string/comment)))) ; just loop
881 On a comment line, go to end of line."
883 (while (let (comment)
885 ;; we're in a comment.
887 (cond ((eq 'comment (syntax-ppss-context s))
888 (setq comment t)
898 (unless comment
948 (if (or (python-comment-line-p)
965 (not (python-comment-line-p))
987 (_ (if (python-comment-line-p)
1012 "`imenu-create-index-function' for Python.
1037 (unless (python-in-string/comment)
1057 (unless (python-in-string/comment)
1079 (not (python-in-string/comment))
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))))
1205 ;; i.e. '>>> ' and not '... '. See the comment before
1262 "`comint-input-filter' function for inferior Python.
1285 "`comint-preoutput-filter-functions' function: ignore prompts not at bol."
1375 ;; Load function definitions we need.
1376 ;; Before the preoutput function was used, this was done via -c in
1421 ;; function to remove the temporary file when it has been evaluated
1423 ;; filter). This function also catches exceptions and truncates
1424 ;; tracebacks not to mention the frame of the function itself.
1468 ;; Fixme: Try to define the function or class within the relevant
1497 :type '(repeat function)
1510 function location information for debugging, and supports users of
1627 (defun python-eldoc-function ()
1629 Only works when point is in a function name, not its arg list, for
1747 "`fill-paragraph-function' handling comments and multi-line strings.
1748 If any of the current line is a comment, fill the comment or the
1749 paragraph of it that point is in, preserving the comment's
1750 indentation and initial comment characters. Similarly if the end
1754 (or (fill-comment-paragraph justify)
1791 COUNT defaults to `python-indent'. If region isn't active, just shift
1800 (setq count python-indent))
1809 (indent-rigidly start end (- count)))))
1815 COUNT defaults to `python-indent'. If region isn't active, just shift
1823 (setq count python-indent))
1824 (indent-rigidly start end count))
1827 "`outline-level' function for Python mode.
1828 The level is the number of `python-indent' steps of indentation
1830 (1+ (/ (current-indentation) python-indent)))
1834 "`add-log-current-defun-function' for Python."
1860 ;; Fixme: Provide a find-function-like command to find source of a
1892 ;; doc for a function in the buffer and the import will lose if the
1974 "Completion function for Python for use with `hippie-expand'."
2027 (function (intern (concat "python-insert-" name))))
2029 (add-to-list 'python-skeletons ',(cons name function))
2031 (define-abbrev python-mode-abbrev-table ,name "" ',function nil t))
2032 (define-skeleton ,function
2035 (put 'def-python-skeleton 'lisp-indent-function 2)
2187 (defvar eldoc-documentation-function)
2248 ;; (font-lock-syntactic-face-function
2249 ;; . python-font-lock-syntactic-face-function)
2253 (set (make-local-variable 'comment-start) "# ")
2254 (set (make-local-variable 'indent-line-function) #'python-indent-line)
2255 (set (make-local-variable 'indent-region-function) #'python-indent-region)
2257 (set (make-local-variable 'fill-paragraph-function) 'python-fill-paragraph)
2259 (set (make-local-variable 'add-log-current-defun-function)
2269 (set (make-local-variable 'beginning-of-defun-function)
2271 (set (make-local-variable 'end-of-defun-function) 'python-end-of-defun)
2272 (setq imenu-create-index-function #'python-imenu-create-index)
2273 (set (make-local-variable 'eldoc-documentation-function)
2274 #'python-eldoc-function)
2288 '((< '(backward-delete-char-untabify (min python-indent
2297 (when python-guess-indent (python-guess-indent))
2299 (unless (= tab-width python-indent)
2300 (setq indent-tabs-mode nil))
2311 (set (make-local-variable 'indent-tabs-mode) nil)))