unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* pYthon indentation
@ 2015-10-22 14:24 rjd
  2015-10-22 15:50 ` Jude DaShiell
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: rjd @ 2015-10-22 14:24 UTC (permalink / raw)
  To: help-gnu-emacs

I have discovered an issue with python-mode in emacs. I generally c++
develop and seldom do python (I have to say that I am not much of a fan, but
our testing framework uses it).

I have recently discovered this issue:

I emacs –Q

I open a python file 

It contains:

Import re as myre

Var = [
%

The % represents the cursor location. Then, at that location I try to tab
and get this error:

Debugger entered--Lisp error: (wrong-type-argument number-or-marker-p nil)
  python-indent-context()
  python-indent--calculate-indentation()
  python-indent-calculate-indentation(nil)
  python-indent-line(nil)
  python-indent-line-function()
  indent-for-tab-command(nil)
  call-interactively(indent-for-tab-command nil nil)
  command-execute(indent-for-tab-command)


I have not developed in python for a month or so but I cannot remember this
being an issue.
I am using emacs 24.5.1 windows 7 64 (unfortunately) and – of course - -Q so
no configuration.

Now, I try to apply python-mode 6.2.1 by running this

Emacs –Q
In *scratch*
(setq load-path (append load-path (list "~/.emacs.d/python-mode.el-6.2.1")))
(require 'python-mode)

I open up a python file (the same as above) then I CAN indent. This is all
well and good, so if I load python-mode 6.2.1 el file in my NORMAL
configuration this solve the issue, BUT now with the new 6.2.1 I do not get
the same theme coloring as before, which-function-mode seems to be broke
(again) and developing in python is sluggish.

For me, unfortunately, 6.2.1 solves one issue but creates others.

If, instead, I can just have the patch that solves the indentation issue,
that would be great.

Thank you.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: pYthon indentation
  2015-10-22 14:24 pYthon indentation rjd
@ 2015-10-22 15:50 ` Jude DaShiell
  2015-10-22 16:04   ` rjd
  2015-10-22 16:20 ` Nick Dokos
  2015-10-22 17:24 ` Andreas Röhler
  2 siblings, 1 reply; 7+ messages in thread
From: Jude DaShiell @ 2015-10-22 15:50 UTC (permalink / raw)
  To: rjd, help-gnu-emacs

I don't know much python yet but have used python-mode to code in 
python2.  When I write something for python a.k.a. python3 though the 
indents are each 2 spaces.  A tab character doesn't work by itself.  For 
that reason python-mode may need reconfiguration to tell it each indent 
is two spaces.  I don't know that using the tab key with python-mode can 
be caused to produce two spaced indents but if so that should solve your 
problem.

On Thu, 22 Oct 2015, rjd wrote:

> Date: Thu, 22 Oct 2015 10:24:10
> From: rjd <ryan.dixon@etas.com>
> To: help-gnu-emacs@gnu.org
> Subject: pYthon indentation
> 
> I have discovered an issue with python-mode in emacs. I generally c++
> develop and seldom do python (I have to say that I am not much of a fan, but
> our testing framework uses it).
>
> I have recently discovered this issue:
>
> I emacs ?Q
>
> I open a python file 
>
> It contains:
>
> Import re as myre
>
> Var = [
> %
>
> The % represents the cursor location. Then, at that location I try to tab
> and get this error:
>
> Debugger entered--Lisp error: (wrong-type-argument number-or-marker-p nil)
>  python-indent-context()
>  python-indent--calculate-indentation()
>  python-indent-calculate-indentation(nil)
>  python-indent-line(nil)
>  python-indent-line-function()
>  indent-for-tab-command(nil)
>  call-interactively(indent-for-tab-command nil nil)
>  command-execute(indent-for-tab-command)
>
>
> I have not developed in python for a month or so but I cannot remember this
> being an issue.
> I am using emacs 24.5.1 windows 7 64 (unfortunately) and ? of course - -Q so
> no configuration.
>
> Now, I try to apply python-mode 6.2.1 by running this
>
> Emacs ?Q
> In *scratch*
> (setq load-path (append load-path (list "~/.emacs.d/python-mode.el-6.2.1")))
> (require 'python-mode)
>
> I open up a python file (the same as above) then I CAN indent. This is all
> well and good, so if I load python-mode 6.2.1 el file in my NORMAL
> configuration this solve the issue, BUT now with the new 6.2.1 I do not get
> the same theme coloring as before, which-function-mode seems to be broke
> (again) and developing in python is sluggish.
>
> For me, unfortunately, 6.2.1 solves one issue but creates others.
>
> If, instead, I can just have the patch that solves the indentation issue,
> that would be great.
>
> Thank you.

-- 




^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: pYthon indentation
  2015-10-22 15:50 ` Jude DaShiell
@ 2015-10-22 16:04   ` rjd
  0 siblings, 0 replies; 7+ messages in thread
From: rjd @ 2015-10-22 16:04 UTC (permalink / raw)
  To: help-gnu-emacs

Jude DaShiell <jdashiel <at> panix.com> writes:

> 
> I don't know much python yet but have used python-mode to code in 
> python2.  When I write something for python a.k.a. python3 though the 
> indents are each 2 spaces.  A tab character doesn't work by itself.  For 
> that reason python-mode may need reconfiguration to tell it each indent 
> is two spaces.  I don't know that using the tab key with python-mode can 
> be caused to produce two spaced indents but if so that should solve your 
> problem.
> 


I never use tab characters in python-mode. I have it set so that TAB will
really insert 4 spaces since those are our coding guidelines. This must be
some sort of bug (I have posted at stackoverflow too:
http://stackoverflow.com/questions/33283860/emacs-24-5-python-mode-stock-version-vs-6-2-1
since I was having a hard time posting on gmane).

Thank you for your response.

When I load python-mode from 6.2.1 indentation works, but 6.2.1 IMO contains
regressions that I just do not want. I was thinking about just hacking my
own indentation function - easy when you are indenting from col 0, but there
is complexity when dealing with non col 0 and auto indentation.

Here is my snippet of .emacs:

(c-set-offset 'inline-open '0) ; This one because of indentation INSIDE
class def
(setq-default indent-tabs-mode nil)
(setq-default tab-width 3)
(setq indent-line-function 'insert-tab)
(setq-default c-basic-offset 3)
(setq-default sh-basic-offset 4)
(setq-default sh-indentation 4)
(setq-default python-indent-offset 4)
(setq-default c-default-style "linux")
(setq c-default-style
      '((java-mode . "java")
        (awk-mode . "awk")
        (other . "linux")))





^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: pYthon indentation
  2015-10-22 14:24 pYthon indentation rjd
  2015-10-22 15:50 ` Jude DaShiell
@ 2015-10-22 16:20 ` Nick Dokos
  2015-10-26 11:52   ` rjd
  2015-10-22 17:24 ` Andreas Röhler
  2 siblings, 1 reply; 7+ messages in thread
From: Nick Dokos @ 2015-10-22 16:20 UTC (permalink / raw)
  To: help-gnu-emacs

rjd <ryan.dixon@etas.com> writes:

> I have discovered an issue with python-mode in emacs. I generally c++
> ...
> For me, unfortunately, 6.2.1 solves one issue but creates others.
>
> If, instead, I can just have the patch that solves the indentation issue,
> that would be great.
>

There are two competing python modes for emacs, python-mode.el (which is
what you are talking about IIUC) and python.el which comes with the
emacs distro. I was using python-mode.el for a while and I always seemed
to have small annoyances crop up at a regular rate (although I must
admit, I never did much to improve the situation: they usually cropped
up when I was under time pressure, so I would just bulldoze my way
through - by the time I *could* do something about it, I had forgotten
what the annoyance was - until the next time something bit me...)

So at some point, I chucked it and started using the built-in python.el.
I'm sure it too has its share of faults, but so far at least (I've been
using it for the past year or so), I don't remember being really annoyed
with it, so I'm sticking with it.

My 2 cents and of course, YMMV.
--
Nick





^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: pYthon indentation
  2015-10-22 14:24 pYthon indentation rjd
  2015-10-22 15:50 ` Jude DaShiell
  2015-10-22 16:20 ` Nick Dokos
@ 2015-10-22 17:24 ` Andreas Röhler
  2015-10-26 11:05   ` rjd
  2 siblings, 1 reply; 7+ messages in thread
From: Andreas Röhler @ 2015-10-22 17:24 UTC (permalink / raw)
  To: help-gnu-emacs

  On 22.10.2015 16:24, rjd wrote:
> I have discovered an issue with python-mode in emacs. I generally c++
> develop and seldom do python (I have to say that I am not much of a fan, but
> our testing framework uses it).
>
> I have recently discovered this issue:
>
> I emacs –Q
>
> I open a python file
>
> It contains:
>
> Import re as myre
>
> Var = [
> %
>
> The % represents the cursor location. Then, at that location I try to tab
> and get this error:
>
> Debugger entered--Lisp error: (wrong-type-argument number-or-marker-p nil)
>    python-indent-context()
>    python-indent--calculate-indentation()
>    python-indent-calculate-indentation(nil)
>    python-indent-line(nil)
>    python-indent-line-function()
>    indent-for-tab-command(nil)
>    call-interactively(indent-for-tab-command nil nil)
>    command-execute(indent-for-tab-command)
>
>
> I have not developed in python for a month or so but I cannot remember this
> being an issue.
> I am using emacs 24.5.1 windows 7 64 (unfortunately) and – of course - -Q so
> no configuration.
>
> Now, I try to apply python-mode 6.2.1 by running this
>
> Emacs –Q
> In *scratch*
> (setq load-path (append load-path (list "~/.emacs.d/python-mode.el-6.2.1")))
> (require 'python-mode)
>
> I open up a python file (the same as above) then I CAN indent. This is all
> well and good, so if I load python-mode 6.2.1 el file in my NORMAL
> configuration this solve the issue, BUT now with the new 6.2.1 I do not get
> the same theme coloring as before, which-function-mode seems to be broke
> (again) and developing in python is sluggish.
>
> For me, unfortunately, 6.2.1 solves one issue but creates others.
>
> If, instead, I can just have the patch that solves the indentation issue,
> that would be great.
>
> Thank you.

Please do not cross-post. Just for the record here again;

python-mode.el's py-variable-name-face inherits default face. Use M-x 
customize-face RET ...

Please file bugs reports at

https://gitlab.com/python-mode-devs/python-mode/issues

or

https://bugs.launchpad.net/python-mode




^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: pYthon indentation
  2015-10-22 17:24 ` Andreas Röhler
@ 2015-10-26 11:05   ` rjd
  0 siblings, 0 replies; 7+ messages in thread
From: rjd @ 2015-10-26 11:05 UTC (permalink / raw)
  To: help-gnu-emacs

Andreas Röhler <andreas.roehler <at> easy-emacs.de> writes:
> 
> Please do not cross-post. Just for the record here again;
> 
> python-mode.el's py-variable-name-face inherits default face. Use M-x 
> customize-face RET ...
> 
> Please file bugs reports at
> 
> https://gitlab.com/python-mode-devs/python-mode/issues
> 
> or
> 
> https://bugs.launchpad.net/python-mode
> 
> 

Thank you, the problem has been reported:

https://gitlab.com/python-mode-devs/python-mode/issues
(Identation ELisp Error)

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: pYthon indentation
  2015-10-22 16:20 ` Nick Dokos
@ 2015-10-26 11:52   ` rjd
  0 siblings, 0 replies; 7+ messages in thread
From: rjd @ 2015-10-26 11:52 UTC (permalink / raw)
  To: help-gnu-emacs

Nick Dokos <ndokos <at> gmail.com> writes:

> There are two competing python modes for emacs, python-mode.el (which is
> what you are talking about IIUC) and python.el which comes with the
> emacs distro. I was using python-mode.el for a while and I always seemed
> to have small annoyances crop up at a regular rate (although I must
> admit, I never did much to improve the situation: they usually cropped
> up when I was under time pressure, so I would just bulldoze my way
> through - by the time I *could* do something about it, I had forgotten
> what the annoyance was - until the next time something bit me...)
> 
> So at some point, I chucked it and started using the built-in python.el.
> I'm sure it too has its share of faults, but so far at least (I've been
> using it for the past year or so), I don't remember being really annoyed
> with it, so I'm sticking with it.
> 
> My 2 cents and of course, YMMV.
> --
> Nick
> 
> 

This was the confusion. The error I am talking about is clearly with
python.el. I have never used python-mode.el until trying to solve this
indentation issue.

The steps to reproduce on Windows 7 (64bit):
i. I downloaded
http://ftp.gnu.org/gnu/emacs/windows/emacs-24.5-bin-i686-mingw32.zip.

ii. I extracted zip file to temp folder; completely unmodified.

iii. I opened an MSYS shell and cd'd into the temp/bin folder.

iv. I ran ./emacs.exe -Q.

v. I C-x C-f and call the new file temp.py

vi. I type the following up UNTIL % - which represents the cursor position:

import re as myre
var = [
%

vii. I then press TAB and get the following message in the mini buffer:

python-indent--calculate-indentation: Wrong type argument:
number-or-marker-p, nil

viii. The debug information shows:

Debugger entered--Lisp error: (wrong-type-argument number-or-marker-p nil)
python-indent-context()
python-indent--calculate-indentation()
python-indent-calculate-indentation(nil)
python-indent-line(nil)
python-indent-line-function()
indent-for-tab-command(nil)
call-interactively(indent-for-tab-command nil nil)
command-execute(indent-for-tab-command)




^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2015-10-26 11:52 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-10-22 14:24 pYthon indentation rjd
2015-10-22 15:50 ` Jude DaShiell
2015-10-22 16:04   ` rjd
2015-10-22 16:20 ` Nick Dokos
2015-10-26 11:52   ` rjd
2015-10-22 17:24 ` Andreas Röhler
2015-10-26 11:05   ` rjd

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).