bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#22212: 24.5; Odd return behavior of function lisp-indent-line (minor


From: Jonathan Holmes
Subject: bug#22212: 24.5; Odd return behavior of function lisp-indent-line (minor)
Date: Sat, 19 Dec 2015 05:26:25 -0500

(lisp-indent-line) generally has an [undocumented] return value of
(point), but when embedded in structures with a number of commands that move
the point, it may return nil instead. I learned about the return value
of (point) from experimentatal evaluation, and then tried to use this to
write the following function:

(defun lisp-indent-lines (lnum1 lnum2)
       (let ((count 0)
    (pos (point)))
       (goto-char 0) (forward-line (- lnum1 1))
       (while (<= lnum1 lnum2)
(back-to-indentation)
(setq count (- count (- (point) (lisp-indent-line))))
(forward-line) (cl-incf lnum1))
       (goto-char (+ pos count))))

This exits with a type error because
     (lisp-indent-line)
returns nil. But if you execute

        (setq count 0)
        (setq count (- count (- (point) (lisp-indent-line))))

outside of a loop or recursion and outside of let/let* bindings,
it has no problem. The only problem with

        (lisp-indent-line)

is the inconsistent return value, so this isa very minor bug,
unless it is some kind of esoteric feature used
in emacs at some phase. The setq statement is not related to the
nil value, though it's the subtraction by nil in that statement that
causes the error -- it will also evaluate to nil in working functions that
avoid relying on its return value.

Similar behavior exists for every method I tested of placing
(lisp-indent-line) in a loop, including dolists and recursive functions,
named or anonymous. Furthermore, sometimes you *can*
evaluate

       (setq count (- count (- (point) (lisp-indent-line))))
            
inside a loop! You can evaluate it unless you also use one of a number
of commands that moves the cursor, such as (forward-line), (goto-line),
(back-to-indentation), or (goto-char).

I believe that the nil return value only occurs when 

I think the function comes from common-lisp-indent-line as implemented in
.../lisp/emacs-lisp/cl-indent.el?




In GNU Emacs 24.5.1 (x86_64-pc-linux-gnu, GTK+ Version 3.10.8)
 of 2015-08-20 on lgw01-16, modified by Debian
Windowing system distributor `The X.Org Foundation', version 11.0.11501000
System Description: Ubuntu 14.04.3 LTS

Configured using:
 `configure --build x86_64-linux-gnu --prefix=/usr
 --sharedstatedir=/var/lib --libexecdir=/usr/lib
 --localstatedir=/var/lib --infodir=/usr/share/info
 --mandir=/usr/share/man --with-pop=yes
 --enable-locallisppath=/etc/emacs24:/etc/emacs:/usr/local/share/emacs/24.5/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/24.5/site-lisp:/usr/share/emacs/site-lisp
 --build x86_64-linux-gnu --prefix=/usr --sharedstatedir=/var/lib
 --libexecdir=/usr/lib --localstatedir=/var/lib
 --infodir=/usr/share/info --mandir=/usr/share/man --with-pop=yes
 --enable-locallisppath=/etc/emacs24:/etc/emacs:/usr/local/share/emacs/24.5/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/24.5/site-lisp:/usr/share/emacs/site-lisp
 --with-x=yes --with-x-toolkit=gtk3 --with-toolkit-scroll-bars
 'CFLAGS=-g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat
 -Werror=format-security -Wall' CPPFLAGS=-D_FORTIFY_SOURCE=2
 'LDFLAGS=-Wl,-Bsymbolic-functions -Wl,-z,relro''

Important settings:
  value of $LANG: en_US.UTF-8
  value of $XMODIFIERS: @im=ibus
  locale-coding-system: utf-8-unix

Major mode: Emacs-Lisp

Minor modes in effect:
  TeX-PDF-mode: t
  show-paren-mode: t
  pdf-occur-global-minor-mode: t
  image-diredx-async-mode: t
  image-diredx-adjust-mode: t
  tooltip-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  column-number-mode: t
  line-number-mode: t
  transient-mark-mode: t

Recent messages:
nil
eval: Symbol's function definition is void: current-minor-modes
Making completion list...
Quit [2 times]
Making completion list...
eval: Symbol's function definition is void: mode-local-active-mode
nil
<C-mouse-1> is undefined
Quit
Making completion list...

Load-path shadows:
/usr/share/emacs/24.5/site-lisp/debian-startup hides /usr/share/emacs/site-lisp/debian-startup

Features:
(god-mode eieio-opt speedbar sb-image ezimage dframe find-func shadow
sort face-remap gnus-util mail-extr emacsbug message rfc822 mml mml-sec
mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils
mailheader sendmail rfc2047 rfc2045 ietf-drums mm-util mail-prsvr
mail-utils term disp-table ehelp misearch multi-isearch help-mode debug
warnings easy-mmode smartparens-latex smartparens thingatpt dash cl-macs
gv tex dbus xml crm my-theme-theme paren key-chord pdf-occur ibuf-ext
ibuffer tablist tablist-filter semantic/wisent/comp semantic/wisent
semantic/wisent/wisent semantic/util-modes semantic/util semantic
semantic/tag semantic/lex semantic/fw eieio byte-opt bytecomp
byte-compile cl-extra cconv eieio-core mode-local cedet pdf-isearch
let-alist pdf-misc imenu pdf-tools compile comint ansi-color ring
cus-edit cus-start cus-load wid-edit pdf-view mule-util bookmark pp
jka-compr pdf-cache pdf-info tq pdf-util image-mode edmacro kmacro
tex-site info easymenu image-dired+ image-dired format-spec dired advice
help-fns cl-loaddefs cl-lib package epg-config time-date tooltip
electric uniquify ediff-hook vc-hooks lisp-float-type mwheel x-win x-dnd
tool-bar dnd fontset image regexp-opt fringe tabulated-list newcomment
lisp-mode prog-mode register page menu-bar rfn-eshadow timer select
scroll-bar mouse jit-lock font-lock syntax facemenu font-core frame cham
georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao
korean japanese hebrew greek romanian slovak czech european ethiopic
indian cyrillic chinese case-table epa-hook jka-cmpr-hook help simple
abbrev minibuffer nadvice loaddefs button faces cus-face macroexp files
text-properties overlay sha1 md5 base64 format env code-pages mule
custom widget hashtable-print-readable backquote make-network-process
dbusbind gfilenotify dynamic-setting system-font-setting
font-render-setting move-toolbar gtk x-toolkit x multi-tty emacs)

Memory information:
((conses 16 265106 81203)
 (symbols 48 33379 0)
 (miscs 40 2053 866)
 (strings 32 65718 4528)
 (string-bytes 1 2079482)
 (vectors 16 34848)
 (vector-slots 8 867195 55107)
 (floats 8 143 510)
 (intervals 56 2286 50)
 (buffers 960 18)
 (heap 1024 46373 8212))


reply via email to

[Prev in Thread] Current Thread [Next in Thread]