GNU bug report logs - #29414
24.5; failure to configure a particular Ocaml indentation parameter (via SMIE)

Previous Next

Package: emacs;

Reported by: Matej Košík <mail <at> matej-kosik.net>

Date: Thu, 23 Nov 2017 17:15:01 UTC

Severity: minor

Tags: fixed, patch

Merged with 24848

Found in version 24.5

Fixed in version 26.1

Done: Noam Postavsky <npostavs <at> users.sourceforge.net>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 29414 in the body.
You can then email your comments to 29414 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#29414; Package emacs. (Thu, 23 Nov 2017 17:15:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Matej Košík <mail <at> matej-kosik.net>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Thu, 23 Nov 2017 17:15:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Matej Košík <mail <at> matej-kosik.net>
To: bug-gnu-emacs <at> gnu.org
Cc: monnier <at> IRO.UMontreal.CA
Subject: 24.5; failure to configure a particular Ocaml indentation parameter
 (via SMIE)
Date: Thu, 23 Nov 2017 16:59:20 +0100
[Message part 1 (text/plain, inline)]
Hi,

I would like to configure Emacs, while editing Ocaml code, so that it
indents the code consistently with the way how "Ocaml Batteries Included" is indented.
(or any kind of sane convention --- I don't care particularly which one
 as long as I can override the default behavior which I find distracting)

However, my attempts to do this failed.

This is what I have tried to do:

------------------------------------------------------------------------------

- I have "tuareg 2.1.0" installed

- My "~/.emacs" file contains only the following line:

    (load "/home/mkosik/.opam/4.06.0/share/emacs/site-lisp/tuareg-site-file")

  It is the line that was printed as a suggestion at the end of the Tuareg installation (via OPAM).

- NOTE: The designated file

    /home/mkosik/.opam/4.06.0/share/emacs/site-lisp/tuareg-site-file

  does not exist. Is that to be expected?

- I go to this line:

    https://github.com/ocaml-batteries-team/batteries-included/blob/e069e28678a0d15d338721e1ff5e480fe0ad26c5/src/batComplex.ml#L82-L83

- change the indentation to a non-default value (e.g. moving that line 4 more spaces to the right)
  (NOTE: at this point, I have just randomly chosen any non-default value)

- I run the following command:

    M-x smie-config-set-indent

  I see the following question

    Adjust rule (:before "|-or" -> nil) to (default 4)

  I press ENTER.

  Then I see a message:

    Added rule :before "|-or" -> 4 (via nil)

- I run the following command:

    smie-config-save

  I see a message:

    Local rules saved in `smie-config`

- I run the following command:

    M-: (print smie-config)

  I see

    ((tuareg-mode (4 :before "|-or" nil)))
    ((tuareg-mode (4 :before "|-or" nil)))

  I have no idea whether this an expected or unexpected value. :-/

- I run the following command:

    M-x customize-save-customized

  I see a message:

    Wrote /home/mkosik/.emacs

- Now my ~/.emacs file looks like this:

    (load "/home/mkosik/.opam/4.06.0/share/emacs/site-lisp/tuareg-site-file")
    (custom-set-variables
     ;; custom-set-variables was added by Custom.
     ;; If you edit it by hand, you could mess it up, so be careful.
     ;; Your init file should contain only one such instance.
     ;; If there is more than one, they won't work right.
     '(inhibit-startup-screen t)
     '(smie-config (quote ((tuareg-mode (4 :before "|-or" nil))))))
    (custom-set-faces
     ;; custom-set-faces was added by Custom.
     ;; If you edit it by hand, you could mess it up, so be careful.
     ;; Your init file should contain only one such instance.
     ;; If there is more than one, they won't work right.
     )

  NOTE: I have no idea whether this is an expected value or not.
        I do not understand the meaning of "smie-config" variable.

I am now going to test whether my setting had any effect, so:

- I close my Emacs window.

- I launch Emacs again with the same file and I place the cursor to the same line as before:

    https://github.com/ocaml-batteries-team/batteries-included/blob/e069e28678a0d15d338721e1ff5e480fe0ad26c5/src/batComplex.ml#L82-L83

- I press TAB.

  What I see is that the whole line is shifted to the right by 2 columns.

I don't understand why by 2 columns to the right?

Why wasn't the line indented by 4 columns to the right
(this is what I defined above as desired indentation).

Incidentally, whatever value I set as a desired indentation,
after I restart Emacs and press TAB on a given line,
the line always moves by 2 places to the right. Why?

------------------------------------------------------------------------------

In GNU Emacs 24.5.1 (x86_64-pc-linux-gnu, GTK+ Version 3.22.11)
 of 2017-09-12 on hullmann, modified by Debian
Windowing system distributor `The X.Org Foundation', version 11.0.11902000
System Description:	Debian GNU/Linux 9.2 (stretch)

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
 --without-gnutls --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
 --without-gnutls --with-x=yes --with-x-toolkit=gtk3
 --with-toolkit-scroll-bars 'CFLAGS=-g -O2
 -fdebug-prefix-map=/build/emacs24-24.5+1=. -fstack-protector-strong
 -Wformat -Werror=format-security -Wall -fno-PIE' 'CPPFLAGS=-Wdate-time
 -D_FORTIFY_SOURCE=2' 'LDFLAGS=-Wl,-z,relro -no-pie''

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

Major mode: Tuareg

Minor modes in effect:
  tooltip-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-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
  line-number-mode: t
  transient-mark-mode: t

Recent messages:
Loading /etc/emacs/site-start.d/50latex-cjk-common.el (source)...
Loading cjk-enc...done
Loading /etc/emacs/site-start.d/50latex-cjk-common.el (source)...done
Loading /etc/emacs/site-start.d/50noweb.el (source)...done
Loading /home/mkosik/.opam/4.06.0/share/emacs/site-lisp/tuareg-site-file...done
For information about GNU Emacs and the GNU system, type C-h C-a.
Auto-saving...done
Quit
Saving file /home/mkosik/git/other/batteries-included/src/batComplex.ml...
Wrote /home/mkosik/git/other/batteries-included/src/batComplex.ml

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

Features:
(shadow sort gnus-util mail-extr emacsbug message format-spec rfc822 mml
mml-sec mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev
gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums mm-util
help-fns mail-prsvr mail-utils vc-git tuareg speedbar sb-image ezimage
dframe compile comint ansi-color ring smie easymenu 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)

[signature.asc (application/pgp-signature, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#29414; Package emacs. (Thu, 23 Nov 2017 19:26:02 GMT) Full text and rfc822 format available.

Message #8 received at 29414 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> IRO.UMontreal.CA>
To: Matej Košík <mail <at> matej-kosik.net>
Cc: 29414 <at> debbugs.gnu.org, monnier <at> IRO.UMontreal.CA
Subject: Re: bug#29414: 24.5;
 failure to configure a particular Ocaml indentation parameter (via
 SMIE)
Date: Thu, 23 Nov 2017 14:26:57 -0500
forcemerge 24848 29414
thanks

> - I run the following command:
>
>     M-: (print smie-config)
>
>   I see
>
>     ((tuareg-mode (4 :before "|-or" nil)))
>     ((tuareg-mode (4 :before "|-or" nil)))
>
>   I have no idea whether this an expected or unexpected value. :-/

Yes, it's expected because M-: already prints the result of the
evaluation, and `print` returns its argument.  IOW better just use
M-: smie-config RET

> - Now my ~/.emacs file looks like this:
[...]
>      '(smie-config (quote ((tuareg-mode (4 :before "|-or" nil))))))

Looks good.

> - I press TAB.
>   What I see is that the whole line is shifted to the right by 2 columns.

Which is what happens by default, so it shows that the setting didn't
take effect.  I tracked this down and this happens to be a known bug
which was recently fixed in smie.el.  More specifically, it
should be fixed in the current Emacs-26 pretest.

I reproduced the corresponding patch below,


        Stefan


commit a58d0c590a777be98e58cd8c92ee1381e07e9b2d
Author: Noam Postavsky <npostavs <at> gmail.com>
Date:   Wed Aug 30 19:31:48 2017 -0400

    Fix loading of smie-config rules (Bug#24848)
    
    * lisp/emacs-lisp/smie.el (smie-config--setter): Use `set-default'
    instead of `setq-default'.
    (smie-config): Use `custom-initialize-set' instead of
    `custom-initialize-default' as the :initialize argument.
    
diff --git a/lisp/emacs-lisp/smie.el b/lisp/emacs-lisp/smie.el
index 87c4782e21..da1e12b140 100644
--- a/lisp/emacs-lisp/smie.el
+++ b/lisp/emacs-lisp/smie.el
@@ -1956,7 +1956,7 @@ smie-config--mode-hook
 (defvar smie-config--modefuns nil)
 
 (defun smie-config--setter (var value)
-  (setq-default var value)
+  (set-default var value)
   (let ((old-modefuns smie-config--modefuns))
     (setq smie-config--modefuns nil)
     (pcase-dolist (`(,mode . ,rules) value)
@@ -1982,7 +1982,7 @@ smie-config
   ;; FIXME improve value-type.
   :type '(choice (const nil)
                  (alist :key-type symbol))
-  :initialize 'custom-initialize-default
+  :initialize 'custom-initialize-set
   :set #'smie-config--setter)
 
 (defun smie-config-local (rules)




Forcibly Merged 24848 29414. Request was from Stefan Monnier <monnier <at> IRO.UMontreal.CA> to control <at> debbugs.gnu.org. (Thu, 23 Nov 2017 20:00:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#29414; Package emacs. (Thu, 23 Nov 2017 23:10:02 GMT) Full text and rfc822 format available.

Message #13 received at 29414 <at> debbugs.gnu.org (full text, mbox):

From: Matej Košík <mail <at> matej-kosik.net>
To: Stefan Monnier <monnier <at> IRO.UMontreal.CA>
Cc: 29414 <at> debbugs.gnu.org
Subject: Re: bug#29414: 24.5; failure to configure a particular Ocaml
 indentation parameter (via SMIE)
Date: Thu, 23 Nov 2017 22:52:08 +0100
[Message part 1 (text/plain, inline)]
I've compiled Emacs 26.0.90 and made the same experiment.
I can confirm that it is fixed.
(I.e., the values I tried to either via "smie-config-set-indent" command or by editing ~/.emacs file are no longer ignored.)

Thank you very much.

On 11/23/17 20:26, Stefan Monnier wrote:
> forcemerge 24848 29414
> thanks
> 
>> - I run the following command:
>>
>>     M-: (print smie-config)
>>
>>   I see
>>
>>     ((tuareg-mode (4 :before "|-or" nil)))
>>     ((tuareg-mode (4 :before "|-or" nil)))
>>
>>   I have no idea whether this an expected or unexpected value. :-/
> 
> Yes, it's expected because M-: already prints the result of the
> evaluation, and `print` returns its argument.  IOW better just use
> M-: smie-config RET
> 
>> - Now my ~/.emacs file looks like this:
> [...]
>>      '(smie-config (quote ((tuareg-mode (4 :before "|-or" nil))))))
> 
> Looks good.
> 
>> - I press TAB.
>>   What I see is that the whole line is shifted to the right by 2 columns.
> 
> Which is what happens by default, so it shows that the setting didn't
> take effect.  I tracked this down and this happens to be a known bug
> which was recently fixed in smie.el.  More specifically, it
> should be fixed in the current Emacs-26 pretest.
> 
> I reproduced the corresponding patch below,
> 
> 
>         Stefan
> 
> 
> commit a58d0c590a777be98e58cd8c92ee1381e07e9b2d
> Author: Noam Postavsky <npostavs <at> gmail.com>
> Date:   Wed Aug 30 19:31:48 2017 -0400
> 
>     Fix loading of smie-config rules (Bug#24848)
>     
>     * lisp/emacs-lisp/smie.el (smie-config--setter): Use `set-default'
>     instead of `setq-default'.
>     (smie-config): Use `custom-initialize-set' instead of
>     `custom-initialize-default' as the :initialize argument.
>     
> diff --git a/lisp/emacs-lisp/smie.el b/lisp/emacs-lisp/smie.el
> index 87c4782e21..da1e12b140 100644
> --- a/lisp/emacs-lisp/smie.el
> +++ b/lisp/emacs-lisp/smie.el
> @@ -1956,7 +1956,7 @@ smie-config--mode-hook
>  (defvar smie-config--modefuns nil)
>  
>  (defun smie-config--setter (var value)
> -  (setq-default var value)
> +  (set-default var value)
>    (let ((old-modefuns smie-config--modefuns))
>      (setq smie-config--modefuns nil)
>      (pcase-dolist (`(,mode . ,rules) value)
> @@ -1982,7 +1982,7 @@ smie-config
>    ;; FIXME improve value-type.
>    :type '(choice (const nil)
>                   (alist :key-type symbol))
> -  :initialize 'custom-initialize-default
> +  :initialize 'custom-initialize-set
>    :set #'smie-config--setter)
>  
>  (defun smie-config-local (rules)
> 

[signature.asc (application/pgp-signature, attachment)]

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Fri, 22 Dec 2017 12:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 7 years and 177 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.