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

Lines Matching +defs:indent +defs:to

0 ;;; indent.el --- indentation commands for Emacs
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
32 (defgroup indent nil
36 (defcustom standard-indent 4
37 "*Default number of columns for margin-changing functions to indent."
38 :group 'indent
41 (defvar indent-line-function 'indent-relative
42 "Function to indent the current line.
46 Setting this function is all you need to make TAB indent appropriately.
47 Don't rebind TAB unless you really need to.")
49 (defcustom tab-always-indent t
54 Most programming language modes have their own variable to control this,
55 e.g., `c-tab-always-indent', and do not respect this variable."
56 :group 'indent
59 (defun indent-according-to-mode ()
61 The buffer-local variable `indent-line-function' determines how to do this,
62 but the functions `indent-relative' and `indent-relative-maybe' are
65 (if (memq indent-line-function
66 '(indent-relative indent-relative-maybe))
75 (indent-line-to column)
76 (save-excursion (indent-line-to column))))
78 (funcall indent-line-function)))
80 (defun indent-for-tab-command (&optional arg)
82 Depending on `tab-always-indent', either insert a tab or indent.
85 The function actually called to indent is determined by the value of
86 `indent-line-function'."
89 ((or ;; indent-to-left-margin is only meant for indenting,
90 ;; so we force it to always insert a tab here.
91 (eq indent-line-function 'indent-to-left-margin)
92 (and (not tab-always-indent)
97 ;; indenting, so we can't pass them to indent-according-to-mode.
98 ((memq indent-line-function '(indent-relative indent-relative-maybe))
99 (funcall indent-line-function))
101 (indent-according-to-mode))))
108 (if indent-tabs-mode
110 (indent-to (* tab-width (+ count (/ (current-column) tab-width)))))))
112 (defun indent-rigidly (start end arg)
123 (let ((indent (current-indentation))
129 (indent-to (max 0 (+ indent arg)) 0))
134 (defun indent-line-to (column)
135 "Indent current line to COLUMN.
138 (back-to-indentation)
144 (indent-to column))
146 (delete-region (progn (move-to-column column t) (point))
147 (progn (back-to-indentation) (point)))))))
150 "Return the left margin to use for this line.
154 (back-to-indentation)
161 (defun move-to-left-margin (&optional n force)
162 "Move to the left margin of the current line.
164 The column moved to is the one given by the `current-left-margin' function.
165 If the line's indentation appears to be wrong, and this command is called
177 (if (> (move-to-column lm force) lm)
181 (indent-to-left-margin))))))
183 ;; This used to be the default indent-line-function,
185 (defun indent-to-left-margin ()
186 "Indent current line to the column given by `current-left-margin'."
187 (indent-line-to (current-left-margin)))
189 (defun delete-to-left-margin (&optional from to)
191 This deletes to the column given by `current-left-margin'.
195 (goto-char (or to (point-max)))
196 (setq to (point-marker))
199 (while (< (point) to)
200 (delete-region (point) (progn (move-to-left-margin nil t) (point)))
202 (move-marker to nil)))
204 (defun set-left-margin (from to width)
205 "Set the left margin of the region to WIDTH.
206 If `auto-fill-mode' is active, re-fill the region to fit the new margin.
210 (interactive "r\nNSet left margin to column: ")
217 (goto-char to)
219 (setq to (point-marker)))
221 (delete-to-left-margin from to)
222 (put-text-property from to 'left-margin width)
223 (indent-rigidly from to width)
224 (if auto-fill-function (save-excursion (fill-region from to nil t t)))
225 (move-marker to nil))
227 (defun set-right-margin (from to width)
228 "Set the right margin of the region to WIDTH.
229 If `auto-fill-mode' is active, re-fill the region to fit the new margin.
233 (interactive "r\nNSet right margin to width: ")
238 (put-text-property from to 'right-margin width)
239 (if auto-fill-function (save-excursion (fill-region from to nil t t))))
241 (defun alter-text-property (from to prop func &optional object)
244 apply FUNCTION to that value and sets the property to the function's result.
245 Optional fifth argument OBJECT specifies the string or buffer to operate on."
249 end (text-property-not-all begin to prop val object))
252 (if (< begin to)
253 (put-text-property begin to prop (funcall func val) object))))
255 (defun increase-left-margin (from to inc)
257 With no prefix argument, this adds `standard-indent' of indentation.
259 to change the margin by, in characters.
260 If `auto-fill-mode' is active, re-fill the region to fit the new margin."
262 (setq inc (if inc (prefix-numeric-value inc) standard-indent))
267 (goto-char to)
268 (setq to (point-marker)))
269 (alter-text-property from to 'left-margin
271 (indent-rigidly from to inc)
272 (if auto-fill-function (save-excursion (fill-region from to nil t t)))
273 (move-marker to nil))
275 (defun decrease-left-margin (from to inc)
277 With no prefix argument, decrease the indentation by `standard-indent'.
279 to change the margin by, in characters.
280 If `auto-fill-mode' is active, re-fill the region to fit the new margin."
282 (setq inc (if inc (prefix-numeric-value inc) standard-indent))
283 (increase-left-margin from to (- inc)))
285 (defun increase-right-margin (from to inc)
287 With no prefix argument, increase the right margin by `standard-indent'.
289 to change the margin by, in characters. A negative argument decreases
291 If `auto-fill-mode' is active, re-fill the region to fit the new margin."
293 (setq inc (if inc (prefix-numeric-value inc) standard-indent))
295 (alter-text-property from to 'right-margin
298 (fill-region from to nil t t))))
300 (defun decrease-right-margin (from to inc)
302 With no prefix argument, decrease the right margin by `standard-indent'.
304 of width to remove, in characters. A negative argument increases
306 If `auto-fill-mode' is active, re-fills region to fit in new margin."
308 (setq inc (if inc (prefix-numeric-value inc) standard-indent))
309 (increase-right-margin from to (- inc)))
312 "Move to the beginning of the text on this line.
317 \(such as a tab used to indent the first line of a paragraph)."
335 (defvar indent-region-function nil
336 "Short cut function to indent region using `indent-according-to-mode'.
337 A value of nil means really run `indent-according-to-mode' on each line.")
339 (defun indent-region (start end &optional column)
341 A numeric prefix argument specifies a column: indent each line to that column.
349 2) If `indent-region-function' is non-nil, call that function
350 to indent the region.
351 3) Indent each line as specified by the variable `indent-line-function'.
353 Called from a program, START and END specify the region to indent.
355 column to indent to; if it is nil, use one of the three methods above."
369 (if indent-region-function
370 (funcall indent-region-function start end)
376 (funcall indent-line-function))
388 (indent-to column 0))
392 (defun indent-relative-maybe ()
394 If the previous nonblank line has no indent points beyond the
397 See also `indent-relative'."
399 (indent-relative t))
401 (defun indent-relative (&optional unindented-ok)
402 "Space out to under next indent point in previous nonblank line.
403 An indent point is a non-whitespace character following whitespace.
406 If the previous nonblank line has no indent points beyond the
407 column point starts at, `tab-to-tab-stop' is done instead, unless
411 See also `indent-relative-maybe'."
417 indent)
422 (move-to-column start-column)
430 (or (= (point) end) (setq indent (current-column))))))
431 (if indent
433 (indent-to indent 0)
437 (tab-to-tab-stop))))
441 "*List of tab stop positions used by `tab-to-tab-stop'.
442 This should be a list of integers, ordered from smallest to largest."
443 :group 'indent
458 "Edit the tab stops used by `tab-to-tab-stop'.
461 You can add or remove colons and then do \\<edit-tab-stops-map>\\[edit-tab-stops-note-changes] to make changes take effect."
464 (switch-to-buffer (get-buffer-create "*Tab Stops*"))
466 (make-local-variable 'indent-tabs-mode)
467 (setq indent-tabs-mode nil)
473 (indent-to (car tabs) 0)
499 (switch-to-buffer edit-tab-stops-buffer)))
503 (defun tab-to-tab-stop ()
504 "Insert spaces or tabs to next defined tab-stop column.
506 Use \\[edit-tab-stops] to edit them interactively."
516 (indent-to (car tabs)))
519 (defun move-to-tab-stop ()
520 "Move point to next defined tab-stop column.
522 Use \\[edit-tab-stops] to edit them interactively."
529 (move-to-column (car tabs) t)
542 (define-key global-map "\t" 'indent-for-tab-command)
543 (define-key esc-map "\C-\\" 'indent-region)
544 (define-key ctl-x-map "\t" 'indent-rigidly)
545 (define-key esc-map "i" 'tab-to-tab-stop)
548 ;;; indent.el ends here