all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* python-mode broken - zip and git issues
@ 2015-01-31 20:39 Tim Johnson
  2015-01-31 20:56 ` Tim Johnson
  2015-02-01 18:03 ` Andreas Röhler
  0 siblings, 2 replies; 12+ messages in thread
From: Tim Johnson @ 2015-01-31 20:39 UTC (permalink / raw)
  To: Emacs

I'm on Mac OS X 10.7.
I've installed python-mode 
from
http://bazaar.launchpad.net/~python-mode-devs/python-mode/python-mode/revision/1787#python-mode.el
See 
https://bugs.launchpad.net/python-mode/+bug/1416633

So I got an earlier version....

I've used python-mode in the past and loved it, so I'm coming back
to both the mode and emacs after many years.

I've loaded a python code file and run help on 'mode-name and it is
coming up as "Py" for the buffer. Is this correct? I seem to
remember in the past it was "python-mode" ...

I'm confused and understand is important because I've written a
numer of elisp defuns the check for mode-name.

Please advise
thanks
-- 
Tim 
tim at tee jay forty nine dot com or akwebsoft dot com
http://www.akwebsoft.com, http://www.tj49.com



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

* Re: python-mode broken - zip and git issues
  2015-01-31 20:39 python-mode broken - zip and git issues Tim Johnson
@ 2015-01-31 20:56 ` Tim Johnson
  2015-01-31 22:05   ` Drew Adams
  2015-02-01 18:03 ` Andreas Röhler
  1 sibling, 1 reply; 12+ messages in thread
From: Tim Johnson @ 2015-01-31 20:56 UTC (permalink / raw)
  To: Emacs

* Tim Johnson <tim@akwebsoft.com> [150131 11:40]:
> I'm on Mac OS X 10.7.
> I've installed python-mode 
> from
> http://bazaar.launchpad.net/~python-mode-devs/python-mode/python-mode/revision/1787#python-mode.el
> See 
> https://bugs.launchpad.net/python-mode/+bug/1416633
> 
> So I got an earlier version....
> 
> I've used python-mode in the past and loved it, so I'm coming back
> to both the mode and emacs after many years.
> 
> I've loaded a python code file and run help on 'mode-name and it is
> coming up as "Py" for the buffer. Is this correct? I seem to
> remember in the past it was "python-mode" ...
> 
> I'm confused and understand is important because I've written a
> numer of elisp defuns the check for mode-name.
  Duh! Typos : Should have said :

 "I'm confused and understanding mode-name is important because I've
 written a numer of elisp defuns that check for mode-name."

-- 
Tim 
tim at tee jay forty nine dot com or akwebsoft dot com
http://www.akwebsoft.com, http://www.tj49.com



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

* RE: python-mode broken - zip and git issues
  2015-01-31 20:56 ` Tim Johnson
@ 2015-01-31 22:05   ` Drew Adams
  2015-01-31 22:23     ` Tim Johnson
  0 siblings, 1 reply; 12+ messages in thread
From: Drew Adams @ 2015-01-31 22:05 UTC (permalink / raw)
  To: Tim Johnson, Emacs

> I've loaded a python code file and run help on 'mode-name and it is
> coming up as "Py" for the buffer. Is this correct? I seem to
> remember in the past it was "python-mode" ...
> 
> I'm confused and understanding mode-name is important because
> I've written a numer of elisp defuns that check for mode-name.

I don't use python-mode, but it sounds like you are perhaps
confused about `mode-name' vs `major-mode'.

`mode-name' is just the pretty (i.e., displayed) name, which is
a string.  It sounds like what you probably want is `major-mode',
which is a symbol.

For example, for Emacs-Lisp mode:
* `mode-name' is "Emacs-Lisp"
* `major-mode' is `emacs-lisp-mode'

Always consult the doc: `C-h v mode-name'.



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

* Re: python-mode broken - zip and git issues
  2015-01-31 22:05   ` Drew Adams
@ 2015-01-31 22:23     ` Tim Johnson
  2015-02-01 14:38       ` Stefan Monnier
  0 siblings, 1 reply; 12+ messages in thread
From: Tim Johnson @ 2015-01-31 22:23 UTC (permalink / raw)
  To: Emacs

* Drew Adams <drew.adams@oracle.com> [150131 13:06]:
> > I've loaded a python code file and run help on 'mode-name and it is
> > coming up as "Py" for the buffer. Is this correct? I seem to
> > remember in the past it was "python-mode" ...
> > 
> > I'm confused and understanding mode-name is important because
> > I've written a numer of elisp defuns that check for mode-name.
> 
> I don't use python-mode, but it sounds like you are perhaps
> confused about `mode-name' vs `major-mode'.
  :) thanks for setting me straight..
  major-mode it is
  and a similar check can be done using (symbol-name major-mode)
  cheers

> `mode-name' is just the pretty (i.e., displayed) name, which is
> a string.  It sounds like what you probably want is `major-mode',
> which is a symbol.

> For example, for Emacs-Lisp mode:
> * `mode-name' is "Emacs-Lisp"
> * `major-mode' is `emacs-lisp-mode'
> 
> Always consult the doc: `C-h v mode-name'.

-- 
Tim 
tim at tee jay forty nine dot com or akwebsoft dot com
http://www.akwebsoft.com, http://www.tj49.com



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

* Re: python-mode broken - zip and git issues
  2015-01-31 22:23     ` Tim Johnson
@ 2015-02-01 14:38       ` Stefan Monnier
  2015-02-01 15:51         ` Drew Adams
  2015-02-01 20:23         ` Tim Johnson
  0 siblings, 2 replies; 12+ messages in thread
From: Stefan Monnier @ 2015-02-01 14:38 UTC (permalink / raw)
  To: help-gnu-emacs

>   major-mode it is
>   and a similar check can be done using (symbol-name major-mode)
>   cheers

Don't use symbol-name on major-mode.  Just use the symbol itself.
E.g. instead of (equal "foo-mode" (symbol-name major-mode)), you can
test (equal 'foo-mode major-mode).

As for Python mode, you might also like to try the built-in python-mode
that comes bundled with Emacs.


        Stefan




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

* RE: python-mode broken - zip and git issues
  2015-02-01 14:38       ` Stefan Monnier
@ 2015-02-01 15:51         ` Drew Adams
  2015-02-01 17:08           ` Tim Johnson
  2015-02-01 20:23         ` Tim Johnson
  1 sibling, 1 reply; 12+ messages in thread
From: Drew Adams @ 2015-02-01 15:51 UTC (permalink / raw)
  To: help-gnu-emacs

> Don't use symbol-name on major-mode.  Just use the symbol itself.
> E.g. instead of (equal "foo-mode" (symbol-name major-mode)), you can
> test (equal 'foo-mode major-mode).

Or (eq 'foo-mode major-mode).



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

* Re: python-mode broken - zip and git issues
  2015-02-01 15:51         ` Drew Adams
@ 2015-02-01 17:08           ` Tim Johnson
  0 siblings, 0 replies; 12+ messages in thread
From: Tim Johnson @ 2015-02-01 17:08 UTC (permalink / raw)
  To: help-gnu-emacs

* Drew Adams <drew.adams@oracle.com> [150201 07:11]:
> > Don't use symbol-name on major-mode.  Just use the symbol itself.
> > E.g. instead of (equal "foo-mode" (symbol-name major-mode)), you can
> > test (equal 'foo-mode major-mode).
> 
> Or (eq 'foo-mode major-mode).
  Thanks. Great tip guys. 
  
  Didn't know that equal/eq worked on symbols. (help is my friend) 

-- 
Tim 
tim at tee jay forty nine dot com or akwebsoft dot com
http://www.akwebsoft.com, http://www.tj49.com



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

* Re: python-mode broken - zip and git issues
  2015-01-31 20:39 python-mode broken - zip and git issues Tim Johnson
  2015-01-31 20:56 ` Tim Johnson
@ 2015-02-01 18:03 ` Andreas Röhler
  1 sibling, 0 replies; 12+ messages in thread
From: Andreas Röhler @ 2015-02-01 18:03 UTC (permalink / raw)
  To: help-gnu-emacs

On 31.01.2015 21:39, Tim Johnson wrote:
> I'm on Mac OS X 10.7.
> I've installed python-mode
> from
> http://bazaar.launchpad.net/~python-mode-devs/python-mode/python-mode/revision/1787#python-mode.el
> See
> https://bugs.launchpad.net/python-mode/+bug/1416633
>
> So I got an earlier version....

Should be fixed in trunk.




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

* Re: python-mode broken - zip and git issues
  2015-02-01 14:38       ` Stefan Monnier
  2015-02-01 15:51         ` Drew Adams
@ 2015-02-01 20:23         ` Tim Johnson
  2015-02-01 20:34           ` Drew Adams
  2015-02-03 20:21           ` Stefan Monnier
  1 sibling, 2 replies; 12+ messages in thread
From: Tim Johnson @ 2015-02-01 20:23 UTC (permalink / raw)
  To: help-gnu-emacs

* Stefan Monnier <monnier@iro.umontreal.ca> [150201 07:11]:
> >   major-mode it is
> >   and a similar check can be done using (symbol-name major-mode)
> >   cheers
> 
> Don't use symbol-name on major-mode.  Just use the symbol itself.
> E.g. instead of (equal "foo-mode" (symbol-name major-mode)), you can
> test (equal 'foo-mode major-mode).
 
  Suppose I wrote an elisp function that dispatched actions based on
  any number of major modes. 

  Would there be anything wrong about a function like this:
(defun tj-check-mode (prefix)
  "Test the major mode to see if the symbol begins with prefix.
  The test is case insensitive."
    (interactive)
	  (string-prefix-p prefix (symbol-name major-mode) 1))
;; would return t for major-mode 'python or 'python-mode	  

> As for Python mode, you might also like to try the built-in python-mode
> that comes bundled with Emacs.
  
  The Röhler is very feature-rich as opposed to the native 'python
  mode. I can't remember, but I may have started using the Röhler
  before the built-in was implemented.

  -- but sometimes simpler *is* better.
-- 
Tim 
tim at tee jay forty nine dot com or akwebsoft dot com
http://www.akwebsoft.com, http://www.tj49.com



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

* RE: python-mode broken - zip and git issues
  2015-02-01 20:23         ` Tim Johnson
@ 2015-02-01 20:34           ` Drew Adams
  2015-02-01 20:40             ` Tim Johnson
  2015-02-03 20:21           ` Stefan Monnier
  1 sibling, 1 reply; 12+ messages in thread
From: Drew Adams @ 2015-02-01 20:34 UTC (permalink / raw)
  To: Tim Johnson, help-gnu-emacs

> Would there be anything wrong about a function like this:
> (defun tj-check-mode (prefix)
>   "Test the major mode to see if the symbol begins with prefix.
>   The test is case insensitive."
>   (interactive)
>   (string-prefix-p prefix (symbol-name major-mode) 1))
> ;; return t for major-mode 'python or 'python-mode

No, nothing wrong with that.

But:

* Function names ending in `-mode' suggest mode functions.
  The convention for predicates is to use suffix `p' or
  `-p'.  See (elisp) `Coding Conventions'.

* You probably want the doc string to say that it returns
  non-nil if...  Just saying that something tests something
  doesn't tell you how to understand the test result. ;-)

* If you just want to check for those two modes then it
  is more correct to check membership:
    (memq major-mode '(python python-mode))
  That rules out returning non-nil for, say, `pythonesque'.  



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

* Re: python-mode broken - zip and git issues
  2015-02-01 20:34           ` Drew Adams
@ 2015-02-01 20:40             ` Tim Johnson
  0 siblings, 0 replies; 12+ messages in thread
From: Tim Johnson @ 2015-02-01 20:40 UTC (permalink / raw)
  To: help-gnu-emacs

* Drew Adams <drew.adams@oracle.com> [150201 11:35]:
> > Would there be anything wrong about a function like this:
> > (defun tj-check-mode (prefix)
> >   "Test the major mode to see if the symbol begins with prefix.
> >   The test is case insensitive."
> >   (interactive)
> >   (string-prefix-p prefix (symbol-name major-mode) 1))
> > ;; return t for major-mode 'python or 'python-mode
> 
> No, nothing wrong with that.
> 
> But:
> 
> * Function names ending in `-mode' suggest mode functions.
>   The convention for predicates is to use suffix `p' or
>   `-p'.  See (elisp) `Coding Conventions'.
> 
> * You probably want the doc string to say that it returns
>   non-nil if...  Just saying that something tests something
>   doesn't tell you how to understand the test result. ;-)
> 
> * If you just want to check for those two modes then it
>   is more correct to check membership:
>     (memq major-mode '(python python-mode))
>   That rules out returning non-nil for, say, `pythonesque'.  
  good tip on docstring
  ... and I've learned a new function (memq) as well as 
  distinguishing between eq and equal.
  thanks again 
-- 
Tim 
tim at tee jay forty nine dot com or akwebsoft dot com
http://www.akwebsoft.com, http://www.tj49.com



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

* Re: python-mode broken - zip and git issues
  2015-02-01 20:23         ` Tim Johnson
  2015-02-01 20:34           ` Drew Adams
@ 2015-02-03 20:21           ` Stefan Monnier
  1 sibling, 0 replies; 12+ messages in thread
From: Stefan Monnier @ 2015-02-03 20:21 UTC (permalink / raw)
  To: help-gnu-emacs

>   The Röhler is very feature-rich as opposed to the native 'python mode.
>   I can't remember, but I may have started using the Röhler
>   before the built-in was implemented.

There have been several different built-in ones.  The current built-in
one is fairly feature rich, IIUC (I don't use any of them myself).


        Stefan




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

end of thread, other threads:[~2015-02-03 20:21 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-01-31 20:39 python-mode broken - zip and git issues Tim Johnson
2015-01-31 20:56 ` Tim Johnson
2015-01-31 22:05   ` Drew Adams
2015-01-31 22:23     ` Tim Johnson
2015-02-01 14:38       ` Stefan Monnier
2015-02-01 15:51         ` Drew Adams
2015-02-01 17:08           ` Tim Johnson
2015-02-01 20:23         ` Tim Johnson
2015-02-01 20:34           ` Drew Adams
2015-02-01 20:40             ` Tim Johnson
2015-02-03 20:21           ` Stefan Monnier
2015-02-01 18:03 ` Andreas Röhler

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.