Function: hui-select-indent-def

hui-select-indent-def is an interactive and byte-compiled function defined in hui-select.el.

Signature

(hui-select-indent-def POS)

Documentation

If POS is at the first alpha character on a line, return (start . end) region.

The major mode for each supported indented language must be included in the list, hui-select-indent-modes.

Key Bindings

Source Code

;; Defined in ~/.emacs.d/elpa/hyperbole-20260414.325/hui-select.el
(defun hui-select-indent-def (pos)
  "If POS is at the first alpha character on a line, return (start . end) region.

The major mode for each supported indented language must be included in the
list, hui-select-indent-modes."
  (interactive)
  (when (memq major-mode hui-select-indent-modes)
    (save-excursion
      (goto-char pos)
      (when (and
	     ;; Use this function only if point is on the first non-blank
	     ;; character of a block, whatever a block is for the current
	     ;; mode.
	     (cond ((eq major-mode 'kotl-mode)
		    (and (looking-at "[1-9*]") (not (kview:valid-position-p))))
		   ((or (eq major-mode 'outline-mode) selective-display)
		    (save-excursion (beginning-of-line)
				    (looking-at outline-regexp)))
		   ;; After indent in any other mode, must be on an alpha
		   ;; or symbol-constituent character.
		   (t (looking-at "[a-zA-z]\\|\\s_")))
	     ;; Must be at the first non-whitespace character in the line.
	     (= (point) (save-excursion (hui-select-back-to-indentation))))
	(let* ((start-col (current-column))
	       (opoint (if (eq major-mode 'kotl-mode)
			   (progn (kotl-mode:to-valid-position) (point))
			 (beginning-of-line) (point))))
	  (while
	      (and (zerop (forward-line 1))
		   (bolp)
		   (or (progn (hui-select-back-to-indentation)
			      (> (current-column) start-col))
		       ;; If in a text mode, allow outdenting, otherwise
		       ;; only include special lines here indented to the
		       ;; same point as the original line.
		       (and (or (memq major-mode hui-select-text-modes)
				(= (current-column) start-col))
			    (looking-at
			     (or (car (cdr
				       (assq
					major-mode
					hui-select-indent-non-end-regexp-alist)))
				 "\\'"))))))
	  (when (and (looking-at
		      (or (car (cdr (assq major-mode
					  hui-select-indent-end-regexp-alist)))
			  "\\'"))
		     (or (memq major-mode hui-select-text-modes)
			 (= (current-column) start-col)))
	    (forward-line 1))
	  (beginning-of-line)
	  ;; Mark the whole definition
	  (setq hui-select-previous 'indent-def)
	  (hui-select-set-region opoint (point)))))))