Re: emacs question: removing "self" keyword in python-mode

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Apr 08, 2009 at 10:09:09PM -0700, Evan Klitzke wrote:
> 
> I know, this is an emacs question and not a fedora question per se. But
> I've asked my question on the emacs help news group without a response,
> and I know there are some emacs users lurking around these parts, so I
> thought I'd try here :-)
> 
> My question is stated previously at:
> http://groups.google.com/group/gnu.emacs.help/browse_thread/thread/785fb0e6542eda80/1ad000e4fa700e1e
> 
> Basically, emacs uses a big complex regular expression to figure out
 regx? Where?
> what words to highlight in different modes. There seems to be a command
> font-lock-remove-keyword that can be used to safely edit the regular
> expression and remove a keyword from it; but the documentation is pretty
> vague, and the source code for the function is way over my head.
> 
> Thanks for any help!
> 

Caution "self" is a convention of some importance....

See http://www.python.org/doc/2.5.2/tut/node11.html

"""Often, the first argument of a method is called self. This is nothing
more than a convention: the name self has absolutely no special meaning
to Python. (Note, however, that by not following the convention your
code may be less readable to other Python programmers, and it is also
conceivable that a class browser program might be written that relies
upon such a convention.) """

Is this in the class of things not unlike the Emacs programmer that redefines Meta-X?

$ locate py | grep py$ | xargs grep self | wc -l
340949
In ./lisp/progmodes/python.el.gz I see:

             ;; Not real keywords, but close enough to be fontified as such
             "self" "True" "False")

So you could take the hint and go with the flow or edit the .el file to read something like
this for the three not real key words.  The bytecompile it or add it to your own .emacs:

(defvar python-font-lock-keywords
  `(,(rx symbol-start
         ;; From v 2.5 reference, <A7> keywords.
         ;; def and class dealt with separately below
         (or "and" "as" "assert" "break" "continue" "del" "elif" "else"
             "except" "exec" "finally" "for" "from" "global" "if"
             "import" "in" "is" "lambda" "not" "or" "pass" "print"
             "raise" "return" "try" "while" "with" "yield"
             ;; Not real keywords, but close enough to be fontified as such
             "RubarbInTheSpringself" "RubarbInTheSpringTrue" "RubarbInTheSpringFalse")
         symbol-end)





-- 
	T o m  M i t c h e l l 
	Found me a new hat, now what?
t

-- 
fedora-list mailing list
fedora-list@xxxxxxxxxx
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
Guidelines: http://fedoraproject.org/wiki/Communicate/MailingListGuidelines
[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [Fedora Magazine]     [Fedora News]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Maintainers]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Legacy]     [Fedora Desktop]     [Fedora Fonts]     [ATA RAID]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [SSH]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Centos]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Tux]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Asterisk PBX]     [Fedora Sparc]     [Fedora Universal Network Connector]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux