Skip to content

Commit 0c0a44c

Browse files
committed
Don't throw on nil in ess-r-indent-line
ess-calculate-indent can return nil
1 parent 8e5196f commit 0c0a44c

File tree

1 file changed

+19
-19
lines changed

1 file changed

+19
-19
lines changed

lisp/ess-r-mode.el

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1342,25 +1342,25 @@ Then run `inferior-ess-r-reload-hook'."
13421342
(defun ess-r-indent-line ()
13431343
"Indent current line as ESS R code.
13441344
Return the amount the indentation changed by."
1345-
(let ((indent (ess-calculate-indent))
1346-
beg shift-amt
1347-
(case-fold-search nil)
1348-
(pos (- (point-max) (point))))
1349-
(beginning-of-line)
1350-
(setq beg (point))
1351-
(skip-chars-forward " \t")
1352-
(setq shift-amt (- indent (current-column)))
1353-
(if (zerop shift-amt)
1354-
(if (> (- (point-max) pos) (point))
1355-
(goto-char (- (point-max) pos)))
1356-
(delete-region beg (point))
1357-
(indent-to indent)
1358-
;; If initial point was within line's indentation,
1359-
;; position after the indentation.
1360-
;; Else stay at same point in text.
1361-
(when (> (- (point-max) pos) (point))
1362-
(goto-char (- (point-max) pos))))
1363-
shift-amt))
1345+
(when-let ((indent (ess-calculate-indent)))
1346+
(let ((case-fold-search nil)
1347+
(pos (- (point-max) (point)))
1348+
beg shift-amt)
1349+
(beginning-of-line)
1350+
(setq beg (point))
1351+
(skip-chars-forward " \t")
1352+
(setq shift-amt (- indent (current-column)))
1353+
(if (zerop shift-amt)
1354+
(if (> (- (point-max) pos) (point))
1355+
(goto-char (- (point-max) pos)))
1356+
(delete-region beg (point))
1357+
(indent-to indent)
1358+
;; If initial point was within line's indentation,
1359+
;; position after the indentation.
1360+
;; Else stay at same point in text.
1361+
(when (> (- (point-max) pos) (point))
1362+
(goto-char (- (point-max) pos))))
1363+
shift-amt)))
13641364

13651365
(defun ess-r-indent-exp ()
13661366
(save-excursion

0 commit comments

Comments
 (0)