From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Jonathan Holmes Newsgroups: gmane.emacs.bugs Subject: bug#22212: 24.5; Odd return behavior of function lisp-indent-line (minor) Date: Sat, 19 Dec 2015 05:26:25 -0500 Message-ID: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=001a11409b0026bee005273db023 X-Trace: ger.gmane.org 1450548260 459 80.91.229.3 (19 Dec 2015 18:04:20 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 19 Dec 2015 18:04:20 +0000 (UTC) To: 22212@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Dec 19 19:04:11 2015 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1aALrW-0004SZ-Kg for geb-bug-gnu-emacs@m.gmane.org; Sat, 19 Dec 2015 19:04:10 +0100 Original-Received: from localhost ([::1]:38183 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aALrV-00065R-FI for geb-bug-gnu-emacs@m.gmane.org; Sat, 19 Dec 2015 13:04:09 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:59830) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aALrQ-00065G-MG for bug-gnu-emacs@gnu.org; Sat, 19 Dec 2015 13:04:06 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aALrO-0001lk-IA for bug-gnu-emacs@gnu.org; Sat, 19 Dec 2015 13:04:04 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:49581) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aALrO-0001lg-Dz for bug-gnu-emacs@gnu.org; Sat, 19 Dec 2015 13:04:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84) (envelope-from ) id 1aALrO-0000Gb-3C for bug-gnu-emacs@gnu.org; Sat, 19 Dec 2015 13:04:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Jonathan Holmes Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 19 Dec 2015 18:04:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 22212 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.1450548210967 (code B ref -1); Sat, 19 Dec 2015 18:04:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 19 Dec 2015 18:03:30 +0000 Original-Received: from localhost ([127.0.0.1]:57179 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1aALqr-0000FW-Hk for submit@debbugs.gnu.org; Sat, 19 Dec 2015 13:03:30 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:45985) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1aAEij-0004xl-J4 for submit@debbugs.gnu.org; Sat, 19 Dec 2015 05:26:38 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aAEic-0006gK-Kl for submit@debbugs.gnu.org; Sat, 19 Dec 2015 05:26:32 -0500 Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:46868) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aAEic-0006gG-Gl for submit@debbugs.gnu.org; Sat, 19 Dec 2015 05:26:30 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:36947) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aAEia-0000AA-JI for bug-gnu-emacs@gnu.org; Sat, 19 Dec 2015 05:26:30 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aAEiY-0006c8-Jt for bug-gnu-emacs@gnu.org; Sat, 19 Dec 2015 05:26:28 -0500 Original-Received: from mail-io0-x235.google.com ([2607:f8b0:4001:c06::235]:35422) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aAEiY-0006c2-Cy for bug-gnu-emacs@gnu.org; Sat, 19 Dec 2015 05:26:26 -0500 Original-Received: by mail-io0-x235.google.com with SMTP id q126so113849143iof.2 for ; Sat, 19 Dec 2015 02:26:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:date:message-id:subject:from:to:content-type; bh=D4rQI4pAxuSdq+psqL6pU2BEUBlTZnW9Wfz8O84uRm8=; b=kY2dpUJegujF/uBjgxO/GoSOEfbR3b3GsqnpmDLQyCrQ39gneEU8h+tZXKYu/WewE5 xk0V4ZLb3Ed0STBd3c7081Ss7tT8/Esu+N73cUO+AexnR0bDwiYIh9jZud0nNNfIpLa5 gHG7x4fFyXO3MBGuhUoSMKC8BQV0XxnvawJJ+IhsFgg55UDwDIIfJcnOwLeI/i87YWT4 JNB+/zWEUXC7BmczoiI5/q9K3POo5xhGADdi42vyV5nPjGbX+T4QwUqQpJ/U4mGgJhpT NqIm77wrfvna3lco2frGBZw4M3aI8rRF3lSFaNEuMFczp0PmvJp8bvnSZgLVeKB9+Fuj BzYw== X-Received: by 10.107.29.19 with SMTP id d19mr9623761iod.27.1450520785369; Sat, 19 Dec 2015 02:26:25 -0800 (PST) Original-Received: by 10.107.48.67 with HTTP; Sat, 19 Dec 2015 02:26:25 -0800 (PST) X-Google-Sender-Auth: 0MrCrrNoiKmfBkoTle0vrkJbuXs X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Mailman-Approved-At: Sat, 19 Dec 2015 13:03:28 -0500 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:110180 Archived-At: --001a11409b0026bee005273db023 Content-Type: text/plain; charset=UTF-8 (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 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)) --001a11409b0026bee005273db023 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
(lisp-indent-line) generally has an [undocumented] re= turn value of
(point), but when embedded in structures with a= number of commands that move
the point, it may return nil instea= d. I learned about the return value
of (point) from experimentata= l evaluation, and then tried to use this to
write the following function= :

(defun lisp-indent-lines (lnum1 lnum2)
=C2=A0 =C2=A0 =C2=A0 =C2=A0(let ((count 0)
=C2=A0 =C2=A0 (pos (point)))
=C2=A0 =C2= =A0 =C2=A0 =C2=A0(goto-char 0) (forward-line (- lnum1 1))
=C2=A0 = =C2=A0 =C2=A0 =C2=A0(while (<=3D lnum1 lnum2)
(back-to-indentation)
(setq count (- count (- (point) (lisp-in= dent-line))))
(forw= ard-line) (cl-incf lnum1))
=C2=A0 =C2=A0 =C2=A0 =C2=A0(goto-char = (+ pos count))))

This exits with a type error beca= use
=C2=A0 =C2=A0 =C2=A0(lisp-indent-line)
returns nil.= But if you execute

=C2=A0 =C2=A0 =C2=A0 =C2=A0 (s= etq count 0)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 (setq count (- count (- = (point) (lisp-indent-line))))

outside of a loop or= recursion and outside of let/let* bindings,
it has no problem.=C2=A0Th= e only problem with

=C2=A0 =C2=A0 =C2=A0 =C2=A0 (l= isp-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 t= o the
nil value, though it's the subtraction by nil in that s= tatement that
causes the error -- it will also evaluate to nil in= working functions that
avoid relying on its return value.
<= div>
Similar behavior exists for every method I tested of pla= cing
(lisp-indent-line) in a loop, including dolists and recursiv= e functions,
named or anonymous. Furthermore, sometimes you *can*=
evaluate

=C2=A0 =C2=A0 =C2=A0 =C2=A0(se= tq count (- count (- (point) (lisp-indent-line))))
=C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0=C2=A0
inside a loop! You can evaluate= it unless you also use one of a number
of commands that moves th= e cursor, such as (forward-line), (goto-line),
(back-to-indentati= on), or (goto-char).

I believe that the nil return value only occurs= when=C2=A0

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)
= =C2=A0of 2015-08-20 on lgw01-16, modified by Debian
Windowing sys= tem distributor `The X.Org Foundation', version 11.0.11501000
System Description: Ubuntu 14.= 04.3 LTS

Configured using:
=C2=A0`config= ure --build x86_64-linux-gnu --prefix=3D/usr
=C2=A0--sharedstated= ir=3D/var/lib --libexecdir=3D/usr/lib
=C2=A0--localstatedir=3D/va= r/lib --infodir=3D/usr/share/info
=C2=A0--mandir=3D/usr/share/man= --with-pop=3Dyes
=C2=A0--enable-locallisppath=3D/etc/emacs24:/et= c/emacs:/usr/local/share/emacs/24.5/site-lisp:/usr/local/share/emacs/site-l= isp:/usr/share/emacs/24.5/site-lisp:/usr/share/emacs/site-lisp
= =C2=A0--build x86_64-linux-gnu --prefix=3D/usr --sharedstatedir=3D/var/lib<= /div>
=C2=A0--libexecdir=3D/usr/lib --localstatedir=3D/var/lib
=C2=A0--infodir=3D/usr/share/info --mandir=3D/usr/share/man --with-pop=3D= yes
=C2=A0--enable-locallisppath=3D/etc/emacs24:/etc/emacs:/usr/l= ocal/share/emacs/24.5/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share= /emacs/24.5/site-lisp:/usr/share/emacs/site-lisp
=C2=A0--with-x= =3Dyes --with-x-toolkit=3Dgtk3 --with-toolkit-scroll-bars
=C2=A0&= #39;CFLAGS=3D-g -O2 -fstack-protector --param=3Dssp-buffer-size=3D4 -Wforma= t
=C2=A0-Werror=3Dformat-security -Wall' CPPFLAGS=3D-D_FORTIF= Y_SOURCE=3D2
=C2=A0'LDFLAGS=3D-Wl,-Bsymbolic-functions -Wl,-z= ,relro''

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

Major mode: Emacs-Lisp

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

Rec= ent messages:
nil
eval: Symbol's function definitio= n 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 comp= letion list...

Load-path shadows:
/usr/s= hare/emacs/24.5/site-lisp/debian-startup hides /usr/share/emacs/site-lisp/d= ebian-startup

Features:
(god-mode eieio-= opt speedbar sb-image ezimage dframe find-func shadow
sort face-r= emap gnus-util mail-extr emacsbug message rfc822 mml mml-sec
mm-d= ecode 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 c= l-macs
gv tex dbus xml crm my-theme-theme paren key-chord pdf-occ= ur ibuf-ext
ibuffer tablist tablist-filter semantic/wisent/comp s= emantic/wisent
semantic/wisent/wisent semantic/util-modes semanti= c/util semantic
semantic/tag semantic/lex semantic/fw eieio byte-= opt bytecomp
byte-compile cl-extra cconv eieio-core mode-local ce= det pdf-isearch
let-alist pdf-misc imenu pdf-tools compile comint= ansi-color ring
cus-edit cus-start cus-load wid-edit pdf-view mu= le-util bookmark pp
jka-compr pdf-cache pdf-info tq pdf-util imag= e-mode edmacro kmacro
tex-site info easymenu image-dired+ image-d= ired format-spec dired advice
help-fns cl-loaddefs cl-lib package= epg-config time-date tooltip
electric uniquify ediff-hook vc-hoo= ks lisp-float-type mwheel x-win x-dnd
tool-bar dnd fontset image = regexp-opt fringe tabulated-list newcomment
lisp-mode prog-mode r= egister page menu-bar rfn-eshadow timer select
scroll-bar mouse j= it-lock font-lock syntax facemenu font-core frame cham
georgian u= tf-8-lang misc-lang vietnamese tibetan thai tai-viet lao
korean j= apanese hebrew greek romanian slovak czech european ethiopic
indi= an 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<= /div>
custom widget hashtable-print-readable backquote make-network-pro= cess
dbusbind gfilenotify dynamic-setting system-font-setting
font-render-setting move-toolbar gtk x-toolkit x multi-tty emacs)

Memory information:
((conses 16 265106 812= 03)
=C2=A0(symbols 48 33379 0)
=C2=A0(miscs 40 2053 866= )
=C2=A0(strings 32 65718 4528)
=C2=A0(string-bytes 1 2= 079482)
=C2=A0(vectors 16 34848)
=C2=A0(vector-slots 8 = 867195 55107)
=C2=A0(floats 8 143 510)
=C2=A0(intervals= 56 2286 50)
=C2=A0(buffers 960 18)
=C2=A0(heap 1024 46= 373 8212))

--001a11409b0026bee005273db023--