0

The following code is copied from https://github.com/emacs-mirror/emacs/blob/master/lisp/simple.el#L1347-L1358. When I copy it into the body of this question, the indentation goes wrong after line save-excursion. So the code below for details.

I have copied the same code into other website, but nothing appears wrong at all.

(defun what-line ()
  "Print the current buffer line number and narrowed line number of point."
  (interactive)
  (let ((start (point-min))
    (n (line-number-at-pos)))
    (if (= start 1)
    (message "Line %d" n)
      (save-excursion
    (save-restriction
      (widen)
      (message "line %d (narrowed line %d)"
           (+ n (line-number-at-pos start) -1) n))))))
3
  • 2
    There is a {tab} character there. The line above it has 4 {space}s. Do a {tab} -> {spaces} first (in your favorite editor), then copy-paste.
    – rene
    May 19, 2020 at 20:34
  • @rene Indeed, it is caused by tab. I never knew such a problem exists in so. Thanks. May 19, 2020 at 20:50
  • 4
    Do you have a GoFundMe? :-p But seriously, always use spaces. May 19, 2020 at 20:59

0

Browse other questions tagged .