unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Drew Adams <drew.adams@oracle.com>
To: Tim Johnson <tim@akwebsoft.com>, help-gnu-emacs@gnu.org
Subject: RE: python-mode broken - zip and git issues
Date: Sun, 1 Feb 2015 12:34:31 -0800 (PST)	[thread overview]
Message-ID: <34001ff4-02a9-4102-93a0-5240aad40d75@default> (raw)
In-Reply-To: <20150201202313.GA911@mail.akwebsoft.com>

> 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'.  



  reply	other threads:[~2015-02-01 20:34 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2015-02-01 20:40             ` Tim Johnson
2015-02-03 20:21           ` Stefan Monnier
2015-02-01 18:03 ` Andreas Röhler

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=34001ff4-02a9-4102-93a0-5240aad40d75@default \
    --to=drew.adams@oracle.com \
    --cc=help-gnu-emacs@gnu.org \
    --cc=tim@akwebsoft.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).