<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>coder . cl &#187; emacs</title>
	<atom:link href="http://coder.cl/category/programming/emacs/feed/" rel="self" type="application/rss+xml" />
	<link>http://coder.cl</link>
	<description>web developer &#38; system programmer</description>
	<lastBuildDate>Sat, 04 Feb 2012 12:07:01 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>integrating pycheckers and emacs</title>
		<link>http://coder.cl/2011/08/integrating-pycheckers-and-emacs/</link>
		<comments>http://coder.cl/2011/08/integrating-pycheckers-and-emacs/#comments</comments>
		<pubDate>Tue, 09 Aug 2011 17:17:59 +0000</pubDate>
		<dc:creator>Daniel Molina Wegener</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[emacs]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://coder.cl/?p=1728</guid>
		<description><![CDATA[There are many versions of the pycheckers.py script. It is wrapper between various static analysis tools for Python code. I have my own modified version of the pycheckers script and it is running pep8, pychecker, pyflakes and pylint. I have that script integrated with Emacs, so I run the compile command to verify the code [...]]]></description>
			<content:encoded><![CDATA[<p>There are many versions of the <i>pycheckers.py</i> script. It is wrapper between various static analysis tools for Python code. I have my own modified version of the pycheckers script and it is running pep8, pychecker, pyflakes and pylint. I have that script integrated with Emacs, so I run the compile command to verify the code quality. My code should meet all Python standards to pass all checks that are made by those tools.</p>
<p><span id="more-1728"></span></p>
<p>You can download my version of the <a href='http://coder.cl.qfl.wpcdn.arcostream.com/uploads/2011/08/pycheckers.gz'>pycheckers.py</a> script and you must put it on path available from the <tt>PATH</tt> environment variable scope. You must be sure that Emacs finds the pycheckers.py command in your <tt>PATH</tt>.</p>
<pre class="brush: lisp;">

;;; load the python mode.
(autoload 'python-mode
          "python-mode"
          "Mode for editing Python source files")

;;; autoload the python-mode on each opened python file.
(setq auto-mode-alist
		(append '(("\\.py" . python-mode)) auto-mode-alist)))

;;; we ensure that we will use the font-lock mode
;;; on Python files.
(setq font-lock-auto-mode-list
      (list 'python-mode))

;;; finally we create the python mode hook function.
(defun dmw-python-mode-hook ()
  (setq py-indent-offset 4
        py-smart-indentation nil
        py-continuation-offset 4
        indent-tabs-mode nil
        py-pychecker-command "pycheckers"
        py-pychecker-command-args (quote ("")))
  (setq interpreter-mode-alist(cons '("python" . python-mode)
                                    interpreter-mode-alist))
  (eldoc-mode 1)
  (define-key py-mode-map "\C-c\C-w" (lambda ()
                                      (interactive)
                                      (command-execute
                                       'py-pychecker-run)))
  (message ">>> done dmw-python-mode-hook..."))

;;; then we add the hook function.
(add-hook 'python-mode-hook 'dmw-python-mode-hook)
</pre>
<p>I hope that you will enjoy checking your code. You just need to install pep8, pylint, pychecker and pyflakes.</p>
<br/><hr height="1px" width="50%" />
<div style='text-align: center !important;'><b>Copyright © 2011 Daniel Molina Wegener</b><br/><b>Atribución-No Comercial-Sin Derivadas 2.0 Chile</b><br/><a target='_new' rel="license" href="http://creativecommons.org/licenses/by-nc-nd/2.0/cl/"><img alt="Creative Commons License" style="border-width:0" src="http://coder.cl.qfl.wpcdn.arcostream.com/cc88x31.png" /></a></div>
<br/><hr height="1px" width="100%" />
<p><small>© Daniel Molina Wegener for <a href="http://coder.cl">coder . cl</a>, 2011. | <a href="http://coder.cl/2011/08/integrating-pycheckers-and-emacs/">Permalink</a> | <a href="http://coder.cl/2011/08/integrating-pycheckers-and-emacs/#comments">No comment</a><br/>Post tags: <br/></small></p>
<script type="text/javascript"><!--
google_ad_client = "ca-pub-6234432850133541";
/* main-feed */
google_ad_slot = "0763600725";
google_ad_width = 728;
google_ad_height = 90;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
]]></content:encoded>
			<wfw:commentRss>http://coder.cl/2011/08/integrating-pycheckers-and-emacs/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>killing equally named buffers in emacs</title>
		<link>http://coder.cl/2011/05/killing-equally-named-buffers-in-emacs/</link>
		<comments>http://coder.cl/2011/05/killing-equally-named-buffers-in-emacs/#comments</comments>
		<pubDate>Tue, 03 May 2011 12:56:21 +0000</pubDate>
		<dc:creator>Daniel Molina Wegener</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[emacs]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://coder.cl/?p=1466</guid>
		<description><![CDATA[As you know I am an Emacs user. Also, I usually implement small commands on it to help me in my programming tasks. For example while I am working with Django &#8212; the Python framework &#8212; usually I must open various files with the same name, for example views.py and urls.py. Once you have modified [...]]]></description>
			<content:encoded><![CDATA[<p>As you know I am an Emacs user. Also, I usually implement small commands on it to help me in my programming tasks. For example while I am working with Django &mdash; the Python framework &mdash; usually I must open various files with the same name, for example <tt>views.py</tt> and <tt>urls.py</tt>. Once you have modified various of those files and you want to close them, you need to visit each buffer and apply the <tt>kill-buffer</tt> command on each one. I have created &mdash; for my comfort &mdash; a pair of commands that can close various buffers at once.</p>
<p><span id="more-1466"></span></p>
<p>The first one is <tt>batch-kill-buffer-equal-named</tt>, which can kill various unmodified buffers at once. You just need to place your current buffer to the buffer that has the name that you want to kill, and apply that command.</p>
<pre class="brush: lisp;">

(require 'cl)

(defun batch-kill-buffer-equal-named ()
  (interactive)
  (let ((cbn (file-name-nondirectory
              (buffer-file-name
               (current-buffer)))))
    (let ((eqn-nm (lambda (x)
                    (and (not (eq (buffer-file-name x) nil))
                         (and (string= (file-name-nondirectory
                                        (buffer-file-name x))
                                       cbn)
                              (not (buffer-modified-p x))))))
          (tmp-buffer-list (copy-tree (buffer-list))))
      (dolist (cb (remove-if-not eqn-nm tmp-buffer-list))
        (kill-buffer cb)))))
</pre>
<p>The command above uses the standard Emacs Lisp functions, also some Emacs CL (Common Lisp) functions to make some tasks easier. So, you need to use the <tt>cl</tt> package. The other command, applies the same logic, but instead of asking for buffer modifications, it saves the visited buffer and then kills it.</p>
<pre class="brush: lisp;">

(defun batch-kill-buffer-save-equal-named ()
  (interactive)
  (let ((cbn (file-name-nondirectory
              (buffer-file-name
               (current-buffer)))))
    (let ((eqn-nm (lambda (x)
                    (and (not (eq (buffer-file-name x) nil))
                         (and (string= (file-name-nondirectory
                                        (buffer-file-name x))
                                       cbn)))))
          (tmp-buffer-list (copy-tree (buffer-list))))
      (dolist (cb (remove-if-not eqn-nm tmp-buffer-list))
        (progn (save-buffer cb)
               (kill-buffer cb))))))
</pre>
<p>This is one the reasons why I am very pleased to use Emacs, you can extend it and customize it without complex tasks, you just need to know how to program using the Emacs Lisp dialect. Then you can place those commands on binding of your taste, I have those commands configured with the following bindings:</p>
<pre class="brush: lisp;">

(global-set-key "\C-c\C-q" 'batch-kill-buffer-equal-named)
(global-set-key "\C-c\C-a" 'batch-kill-buffer-save-equal-named)
</pre>
<p>I think that you will enjoy your favourite editor&#8230; Emacs :)</p>
<br/><hr height="1px" width="50%" />
<div style='text-align: center !important;'><b>Copyright © 2011 Daniel Molina Wegener</b><br/><b>Atribución-No Comercial-Sin Derivadas 2.0 Chile</b><br/><a target='_new' rel="license" href="http://creativecommons.org/licenses/by-nc-nd/2.0/cl/"><img alt="Creative Commons License" style="border-width:0" src="http://coder.cl.qfl.wpcdn.arcostream.com/cc88x31.png" /></a></div>
<br/><hr height="1px" width="100%" />
<p><small>© Daniel Molina Wegener for <a href="http://coder.cl">coder . cl</a>, 2011. | <a href="http://coder.cl/2011/05/killing-equally-named-buffers-in-emacs/">Permalink</a> | <a href="http://coder.cl/2011/05/killing-equally-named-buffers-in-emacs/#comments">No comment</a><br/>Post tags: <br/></small></p>
<script type="text/javascript"><!--
google_ad_client = "ca-pub-6234432850133541";
/* main-feed */
google_ad_slot = "0763600725";
google_ad_width = 728;
google_ad_height = 90;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
]]></content:encoded>
			<wfw:commentRss>http://coder.cl/2011/05/killing-equally-named-buffers-in-emacs/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>directory based hooks in emacs</title>
		<link>http://coder.cl/2010/10/directory-based-hooks-in-emacs/</link>
		<comments>http://coder.cl/2010/10/directory-based-hooks-in-emacs/#comments</comments>
		<pubDate>Fri, 08 Oct 2010 23:46:09 +0000</pubDate>
		<dc:creator>Daniel Molina Wegener</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[emacs]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://coder.cl/?p=968</guid>
		<description><![CDATA[Some time ago, I was using ecb-mode &#8212; Emacs Code Browser &#8212; hooks to specify which hook will run on certain directory, so I was configuring Emacs to run certain hook based on the directory of the file. The ecb-after-directory-change-hook was great to integrate Emacs and well defined project specific indentation modes for C, C++ [...]]]></description>
			<content:encoded><![CDATA[<p>Some time ago, I was using <b>ecb-mode</b> &mdash; Emacs Code Browser &mdash; hooks to specify which hook will run on certain directory, so I was configuring Emacs to run certain hook based on the directory of the file. The <i>ecb-after-directory-change-hook</i> was great to integrate Emacs and well defined project specific indentation modes for C, C++ and some other languages. Each project has its own indentation style, for example for Python extensions, you must use the <i>python</i> style: <tt>(setq c-default-style "python")</tt>; for the Linux Kernel you must use the <i>&#8220;linux&#8221;</i> style: <tt>(setq c-default-style "linux")</tt>; for GNU related tools, you must use the <i>gnu</i> style: <tt>(setq c-default-style "gnu")</tt> and for the FreeBSD operating system, you must the <i>knf</i> style: <tt>(setq c-default-style "knf")</tt>.</p>
<p><span id="more-968"></span></p>
<p>This small trick, will allow you to use certain style and run your project specific hook based on the directory name or file name that is visited by Emacs.</p>
<pre class="brush: lisp;">
(defvar dmw-visit-file-mode-list
  '(("/home/dmw" caffeine-c-mode-hook)
    ("/work/src/caffeine" caffeine-c-mode-hook)
    ("/work/src/caffeine++" caffeine-c++-mode-hook)
    ("/work/src/fireservice" caffeine-c++-mode-hook)
    ("/work/src/Linux" gnu-c++-mode-hook)
    ("/work/src/FreeBSD" caffeine-c-mode-hook)
    ("/work/src/jaxer/products/server/src" caffeine-c++-mode-hook)
    ("/work/src/syslog-ng" caffeine-c-mode-hook)
    ("/work/src/pyxser" python-c-mode-hook)
    ("/work/gae/gae-1.3.7/cclp" python-mode-hook)
    ("/work/gae/gae-1.3.7/todo" python-mode-hook)
    ("/work/gae/gae-1.3.7" python-mode-hook)
    ("/work/www" dmw-php-mode-hook)))

(defun dmw-directory-based-c-hook ()
  (make-local-variable 'tab-width)
  (make-local-variable 'indent-tabs-mode)
  (make-local-variable 'fill-column)
  (make-local-variable 'tab-width)
  (make-local-variable 'c-tab-always-indent)
  (make-local-variable 'c-auto-hungry-initial-state)
  (make-local-variable 'c-default-style)
  (make-local-variable 'c-indent-level)
  (make-local-variable 'c-auto-hungry-initial-state)
  (make-local-variable 'c-block-comment-prefix)
  (make-local-variable 'c-basic-offset)
  (make-local-variable 'c-offsets-alist)
  (make-local-variable 'c-tab-always-indent)
  (make-local-variable 'fill-column)
  (dolist (dir-mode-pair dmw-ecb-directory-change-alist)
    (let ((dir-name (concat (first dir-mode-pair) ".*"))
          (mode-is (car (last dir-mode-pair)))
          (match-dir-based (string-match
                            (concat (first dir-mode-pair) ".*")
                            (buffer-file-name))))
      (if (and (numberp match-dir-based)
               (>= match-dir-based 0))
          (funcall mode-is))))
  (message ">>> done dmw-directory-based-c-hook..."))
</pre>
<p>Where each hook function on the <i>dmw-visit-file-mode-list</i>, runs each time that a file is visited. For example if I visit a file on the <i>&quot;/work/src/pyxser&quot;</i> directory, it will run the <tt>python-c-mode-hook</tt> function as mode hook.</p>
<pre class="brush: lisp;">
;;; I add dmw-directory-based-c-hook to both C and C++ mode hook lists
(add-hook 'c-mode-hook 'dmw-directory-based-c-hook)
(add-hook 'c++-mode-hook 'dmw-directory-based-c-hook)
;;; instead of adding directly the python-c-mode-hook
(add-hook 'c-mode-hook 'python-c-mode-hook)
;;; which is only one, so, I leave project specific hooks to be handled
;;; based on its directory
</pre>
<p>And the <tt>python-c-mode-hook</tt> hook function, looks as follows:</p>
<pre class="brush: lisp;">
(defun python-c-mode-hook ()
  (setq c-default-style "python")
  (setq tab-width 4)
  (setq indent-tabs-mode nil)
  (setq c-tab-always-indent t)
  (setq c-basic-offset 4)
  (setq c-auto-hungry-initial-state 'none)
  (setq c-tab-always-indent t)
  (setq c-block-comment-prefix "* ")
  (setq fill-column 78)
  (c-set-offset 'arglist-cont 4)
  (c-set-offset 'arglist-cont-nonempty 4)
  (c-set-offset 'statement-cont 4)
  (c-set-offset 'label [0])
  (c-set-style "python")
  (message ">>> done python-c-mode-hook (style %s)" c-indentation-style))
</pre>
<p>Happy programming under Emacs ;)</p>
<br/><hr height="1px" width="50%" />
<div style='text-align: center !important;'><b>Copyright © 2010 Daniel Molina Wegener</b><br/><b>Atribución-No Comercial-Sin Derivadas 2.0 Chile</b><br/><a target='_new' rel="license" href="http://creativecommons.org/licenses/by-nc-nd/2.0/cl/"><img alt="Creative Commons License" style="border-width:0" src="http://coder.cl.qfl.wpcdn.arcostream.com/cc88x31.png" /></a></div>
<br/><hr height="1px" width="100%" />
<p><small>© Daniel Molina Wegener for <a href="http://coder.cl">coder . cl</a>, 2010. | <a href="http://coder.cl/2010/10/directory-based-hooks-in-emacs/">Permalink</a> | <a href="http://coder.cl/2010/10/directory-based-hooks-in-emacs/#comments">No comment</a><br/>Post tags: <br/></small></p>
<script type="text/javascript"><!--
google_ad_client = "ca-pub-6234432850133541";
/* main-feed */
google_ad_slot = "0763600725";
google_ad_width = 728;
google_ad_height = 90;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
]]></content:encoded>
			<wfw:commentRss>http://coder.cl/2010/10/directory-based-hooks-in-emacs/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>emacs as python ide</title>
		<link>http://coder.cl/2010/09/emacs-as-python-ide/</link>
		<comments>http://coder.cl/2010/09/emacs-as-python-ide/#comments</comments>
		<pubDate>Thu, 30 Sep 2010 19:53:45 +0000</pubDate>
		<dc:creator>Daniel Molina Wegener</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[emacs]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[sysadmin]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://coder.cl/?p=951</guid>
		<description><![CDATA[Emacs is a powerful text editor. It has an embedded List dialect interpreter, called Emacs-Lisp and it has many extensions &#8212; called Emacs Modes &#8212; to work in various tasks, from programming tasks, IRC clients, MUAs and time organizing tasks. Many people says that Emacs works likely an Operating System, since it has a lot [...]]]></description>
			<content:encoded><![CDATA[<p>Emacs is a powerful text editor. It has an embedded List dialect interpreter, called Emacs-Lisp and it has many extensions &mdash; called Emacs Modes &mdash; to work in various tasks, from <i>programming</i> tasks, <i>IRC clients</i>, <i>MUAs</i> and <i>time organizing tasks</i>. Many people says that Emacs works likely an Operating System, since it has a lot of applications mounted on top of Emacs Lisp. Python Mode (python-mode) in emacs has been extended and it can be used with various tools, turning your Emacs editor in a powerful IDE to work with Python.</p>
<p><span id="more-951"></span></p>
<p><br/></p>
<h3>python-mode</h3>
<p>Emacs is configured through the Lisp dialect Emacs-Lisp. Core configuration directives are processed from the <tt>~/.emacs</tt> file. To enable the <i>python-mode</i>, you just need to load the python-mode each time that your Emacs editor opens a Python file.</p>
<pre class="brush: lisp;">

;;; auto load python-mode
(autoload 'python-mode "python-mode" "Mode for editing Python source files")

;;; enable python-mode on .py files
(setq auto-mode-alist
      (append '(("\\.py" . python-mode)
                ) auto-mode-alist))

;; auto font lock mode
(defvar font-lock-auto-mode-list
  (list 'python-mode))
</pre>
<p>Also i known that each Emacs Mode, has some hooks, and <i>python-mode</i> isn&#8217;t an exception. To customize the <i>python-mode</i> you can use the <i>python-mode-hook</i> variable:</p>
<pre class="brush: lisp;">

(add-hook 'python-mode-hook 'dmw-python-mode-hook)
</pre>
<p>Where, in this case, <i>dmw-python-mode-hook</i> is a symbol pointing to a function called <i>dmw-python-mode-hook</i>:</p>
<pre class="brush: lisp;">

;; python mode hook
(defun dmw-python-mode-hook ()
  (load "py-mode-ext")
  (load "pyp")
  (require 'pycomplete)
  (setq py-indent-offset 4)
  (setq py-smart-indentation t)
  (setq py-continuation-offset 4)
  (setq indent-tabs-mode nil)
  (setq py-pychecker-command "~/bin/pylint_etc_wrapper.py")
  (setq py-pychecker-command-args (quote ("")))
  (autoload 'pymacs-load "pymacs" nil t)
  (autoload 'pymacs-eval "pymacs" nil t)
  (autoload 'pymacs-apply "pymacs")
  (autoload 'pymacs-call "pymacs")
  (setq interpreter-mode-alist(cons '("python" . python-mode)
                                    interpreter-mode-alist))
  (eldoc-mode 1)
  (define-key py-mode-map [f12] 'pyp)
  (define-key py-mode-map "\C-c\C-w" (lambda ()
                                       (interactive)
                                       (command-execute 'py-pychecker-run)))
  (define-key py-mode-map [C-S-iso-lefttab] 'py-complete)
  )
</pre>
<p><br/></p>
<h3>python-mode-hook</h3>
<p>This python-mode-hook function or hook function, enables a series of features for you python-mode. First, it loads <tt>py-mode-ext</tt> and <tt>pyp</tt>, and also loads <tt>pycomplete</tt>. Those tools are part of the <a href="http://page.sourceforge.net/">PAGE &#8211; Python Automatic GUI Generator</a> package. <tt>py-mode-ext</tt> adds some nice functions and commands, like <tt>py-call-pdb</tt>, to begin debugging Python. <tt>pyp</tt> adds a command/function that prints the current expression, or prompts for an expression to print, with the complete code hierarchy as prefix:</p>
<pre class="brush: python;">

def main():
    if len(sys.argv) != 3:
        print &quot;No dialup number\n&quot;
    txtmsg = sys.argv[2]
    number = sys.argv[1]
    number = number.strip()
    for n in [' ', '+', '(', ')', &quot;\s&quot;, &quot;\t&quot;, '-']:
        number = number.replace(n, &quot;&quot;);
    number = '+' + number
    skype = Skype4Py.Skype()
    skype.Attach()
    ### this line was generated with the pyp
    ### command that has the line
    ### (define-key py-mode-map [f12] 'pyp) on the
    ### python-mode-hook
    print 'main: skype =', skype    # dmw   pyp
    message = skype.CreateSms(Skype4Py.smsMessageTypeOutgoing, number)
    message.Body = txtmsg
    message.Send()
</pre>
<p>Finally the <tt>pycomplete</tt> module has a very nice tool to enable Python auto-completion. For example the following code:</p>
<pre class="brush: python;">

class ParentObject:
    parent1 = None
    parent2 = None
    parent3 = None
    def __init__(self, m1, m2, m3):
        self.parent1 = m1
        self.parent2 = m2
    def child(self, m1, m2, m3):
        self.parent3 = ChildObject(m1, m2, m3)
    def nested(self, m1, m2, m3):
        self.parent3.child4 = NestedChild(m1, m2, m3)
    def subnested(self, m1):
        self.parent3.child4.nested4 = SubNestedChild(m1)
        ### here I press ctrl + s + tab
        ### this will run py-complete as the line
        ### (define-key py-mode-map [C-S-iso-lefttab] 'py-complete)
        ### is defined on the python-mode-hook
        str&lt;Ctrl+S+Tab&gt;
    def __repr__(self):
        return &quot;\n-> &quot; + repr(self.__dict__)
</pre>
<p>This will display a window as follows &mdash; where you just need to press <i>mouse-2</i> or the middle button on your mouse to select one completion:</p>
<div class="figure">
<a href="http://coder.cl.qfl.wpcdn.arcostream.com/uploads/2010/09/python-completions.jpg" target="_blank"><img src="http://coder.cl.qfl.wpcdn.arcostream.com/uploads/2010/09/python-completions.jpg" border="0" /></a>
</div>
<p><br/></p>
<h3>pychecker</h3>
<p>Python static checkers are cool, also are tools that you must use in your daily Python programming tasks. For example, on the <a href="http://www.emacswiki.org">Emacs Wiki</a>, you can find <a href="http://www.emacswiki.org/emacs/PythonProgrammingInEmacs">this article</a> about using Emacs as Python IDE. There I&#8217;ve found the <a href="http://bitbucket.org/tavisrudd/pylint_etc_wrapper.py/src/tip/pylint_etc_wrapper.py">pylint_etc_wrapper.py</a> script, which runs three Python static checkers at once: pylint, pychecker, pyflakes and pep8. Running the pychecker script using the <tt>ctrl + c</tt><tt>ctrl + w</tt> key sequence, you will obtain a window similar to the next one, will errors reported from those tools:</p>
<div class="figure">
<a href="http://coder.cl.qfl.wpcdn.arcostream.com/uploads/2010/09/pychecker.jpg" target="_blank"><img src="http://coder.cl.qfl.wpcdn.arcostream.com/uploads/2010/09/pychecker.jpg" border="0" /></a>
</div>
<p>I hope that you will enjoy <a href="http://en.wikipedia.org/wiki/Hacker_(programmer_subculture)">hacking</a> Python from <a href="http://en.wikipedia.org/wiki/Emacs">Emacs</a>, it&#8217;s a great editor. Also you can use the <a href="http://ecb.sourceforge.net/">Emacs Code Browser</a> with Python, I hope that you can find it very interesting.</p>
<br/><hr height="1px" width="50%" />
<div style='text-align: center !important;'><b>Copyright © 2010 Daniel Molina Wegener</b><br/><b>Atribución-No Comercial-Sin Derivadas 2.0 Chile</b><br/><a target='_new' rel="license" href="http://creativecommons.org/licenses/by-nc-nd/2.0/cl/"><img alt="Creative Commons License" style="border-width:0" src="http://coder.cl.qfl.wpcdn.arcostream.com/cc88x31.png" /></a></div>
<br/><hr height="1px" width="100%" />
<p><small>© Daniel Molina Wegener for <a href="http://coder.cl">coder . cl</a>, 2010. | <a href="http://coder.cl/2010/09/emacs-as-python-ide/">Permalink</a> | <a href="http://coder.cl/2010/09/emacs-as-python-ide/#comments">No comment</a><br/>Post tags: <br/></small></p>
<script type="text/javascript"><!--
google_ad_client = "ca-pub-6234432850133541";
/* main-feed */
google_ad_slot = "0763600725";
google_ad_width = 728;
google_ad_height = 90;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
]]></content:encoded>
			<wfw:commentRss>http://coder.cl/2010/09/emacs-as-python-ide/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>changes in my ecb hooks</title>
		<link>http://coder.cl/2010/08/changes-in-my-ecb-hooks/</link>
		<comments>http://coder.cl/2010/08/changes-in-my-ecb-hooks/#comments</comments>
		<pubDate>Sun, 08 Aug 2010 15:54:24 +0000</pubDate>
		<dc:creator>Daniel Molina Wegener</dc:creator>
				<category><![CDATA[emacs]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://coder.cl/?p=800</guid>
		<description><![CDATA[As you know I&#8217;m an emacs user. I use emacs due its flexibility and extensibility, I&#8217;m using some major modes like CEDET and ECB. I use some hooks to integrate emacs and my common programming tasks. For example, I can&#8217;t imagine programming large projects like the FreeBSD Kernel or Linux Kernel only by using grep(1), [...]]]></description>
			<content:encoded><![CDATA[<p>As you know I&#8217;m an <strong>emacs</strong> user. I use emacs due its flexibility and extensibility, I&#8217;m using some major modes like <i>CEDET</i> and <i>ECB</i>. I use some hooks to integrate <strong>emacs</strong> and my common programming tasks. For example, I can&#8217;t imagine programming large projects like the <a href='http://www.freebsd.org/'>FreeBSD Kernel</a> or <a href='http://www.kernel.org/'>Linux Kernel</a> only by using <strong>grep(1)</strong>, <strong>egrep(1)</strong> or <strong>find(1)</strong>, so I need to index large amount of code files&#8230;</p>
<p><span id="more-800"></span></p>
<p>For indexing tasks I&#8217;ve integrated <i>ECB</i> and <i>cscope-mode</i>, and created some hooks for certain directories. To let <i>ECB</i> know which hook must run on each directory, I&#8217;ve created the following variable in my <tt>.emacs</tt> file:</p>
<pre class='brush: lisp;'>
(defvar dmw-ecb-directory-change-alist
  '((&quot;/work/src/caffeine&quot; caffeine-c-mode-hook)
    (&quot;/work/src/caffeine++&quot; caffeine-c++-mode-hook)
    (&quot;/work/src/fireservice&quot; caffeine-c++-mode-hook)
    (&quot;/work/src/Linux&quot; caffeine-c-mode-hook)
    (&quot;/work/src/FreeBSD&quot; caffeine-c-mode-hook)
    (&quot;/work/src/jaxer/products/server/src&quot; caffeine-c++-mode-hook)
    (&quot;/work/src/syslog-ng&quot; caffeine-c-mode-hook)
    (&quot;/work/src/pyxser&quot; python-c-mode-hook)
    (&quot;/work/gae/gae-1.3.5/cclp&quot; python-mode-hook)
    (&quot;/work/gae/gae-1.3.5&quot; python-mode-hook)))
</pre>
<p>To let <strong>emacs</strong> know which directories requires automatic indexing of <strong>C</strong> code files I&#8217;ve created the following variable:</p>
<pre class='brush: lisp;'>
(defvar dmw-ecb-cscope-autoindexing-projects
  '(&quot;/work/src/caffeine&quot;
    &quot;/work/src/caffeine++&quot;
    &quot;/work/src/fireservice&quot;
    &quot;/work/src/Linux&quot;
    &quot;/work/src/FreeBSD&quot;
    &quot;/work/src/jaxer/products/server/src&quot;
    &quot;/work/src/syslog-ng&quot;
    &quot;/work/src/pyxser&quot;))
</pre>
<p>And created the following hook to make each <strong>emacs</strong> sessions something really productive:</p>
<pre class='brush: lisp;'>
(defun dmw-ecb-directory-change-hook (dirold dirnew)
  (dolist (prji dmw-ecb-directory-change-alist)
    (let ((prj-name (first prji))
          (prj-match (string-match (concat (first prji) &quot;.*&quot;) dirnew))
          (prj-hook (last prji))
          )
      (if (numberp prj-match)
          (progn
            (if (&gt;= prj-match 0)
                (dolist (h (last prji))
                  (run-hook-with-args h)))
            (dolist (cscope-auto dmw-ecb-cscope-autoindexing-projects)
              (let ((newpath (concat dirnew &quot;/cscope.out&quot;))
                    (dirnew dirnew))
                (if (and (string= prj-name cscope-auto)
                         (not (file-exists-p cscope-auto)))
                    (progn
                      (setq cscope-database-file newpath
                            cscope-do-not-update-database nil
                            cscope-use-relative-path t
                            cscope-initial-directory dirnew)
                      (cscope-index-files dirnew)))))
            )))))

(defun dmw-cedet-hook ()
  (local-set-key [(control return)] 'semantic-ia-complete-symbol)
  (local-set-key &quot;\C-c?&quot; 'semantic-ia-complete-symbol-menu)
  (local-set-key &quot;\C-c&gt;&quot; 'semantic-complete-analyze-inline)
  (local-set-key &quot;\C-cp&quot; 'semantic-analyze-proto-impl-toggle))

(add-hook 'c-mode-common-hook
          'dmw-cedet-hook)

(add-hook 'ecb-after-directory-change-hook
          'dmw-ecb-directory-change-hook)

(global-ede-mode t)
</pre>
<p>The <i>dmw-ecb-directory-change-hook</i> run each hook associated with project directories in the <i>dmw-ecb-directory-change-alist</i> list and also, it verify if the directory is present in the <i>dmw-ecb-cscope-autoindexing-projects</i>, and if the directory is on the list, it will call the <tt>cscope-index-files</tt> function to index the directory using <strong>cscope(1)</strong>.</p>
<p>Also, here is my <i>ecb-activate-hook</i>, which makes coding under <strong>emacs</strong> quite more productive, and make its behaviour very similar to any another IDE:</p>
<pre class='brush: lisp;'>
(defun dmw-ecb-activate-hook ()
  (custom-set-variables
   '(ecb-display-default-dir-after-start t)
   '(ecb-auto-activate nil)
   '(ecb-options-version &quot;2.32&quot;)
   '(ecb-source-path dmw-ecb-working-projects)
   '(ecb-tip-of-the-day nil)
   '(cache-directory-contents
     (quote ((&quot;.*caffeine&quot; . 10000)
             (&quot;.*caffeine++&quot; . 10000)
             (&quot;.*pyxser&quot; . 10000)
             (&quot;.*fireservice&quot; . 10000)
             (&quot;.*src/&quot; . 10000))))
   )
  (setq-mode-local c-mode semanticdb-find-default-throttle
                   '(project unloaded system recursive))
  (setq-mode-local c++-mode semanticdb-find-default-throttle
                   '(project unloaded system recursive))
  (semantic-add-system-include &quot;/usr/include&quot; 'c++-mode)
  (semantic-add-system-include &quot;/usr/local/include&quot; 'c++-mode)
  (semantic-add-system-include &quot;/usr/include&quot; 'c-mode)
  (semantic-add-system-include &quot;/usr/local/include&quot; 'c-mode)
  (message &quot;ECB Activate Hook Done!&quot;))
</pre>
<p><strong>emacs</strong> rocks ;)</p>
<br/><hr height="1px" width="50%" />
<div style='text-align: center !important;'><b>Copyright © 2010 Daniel Molina Wegener</b><br/><b>Atribución-No Comercial-Sin Derivadas 2.0 Chile</b><br/><a target='_new' rel="license" href="http://creativecommons.org/licenses/by-nc-nd/2.0/cl/"><img alt="Creative Commons License" style="border-width:0" src="http://coder.cl.qfl.wpcdn.arcostream.com/cc88x31.png" /></a></div>
<br/><hr height="1px" width="100%" />
<p><small>© Daniel Molina Wegener for <a href="http://coder.cl">coder . cl</a>, 2010. | <a href="http://coder.cl/2010/08/changes-in-my-ecb-hooks/">Permalink</a> | <a href="http://coder.cl/2010/08/changes-in-my-ecb-hooks/#comments">No comment</a><br/>Post tags: <br/></small></p>
<script type="text/javascript"><!--
google_ad_client = "ca-pub-6234432850133541";
/* main-feed */
google_ad_slot = "0763600725";
google_ad_width = 728;
google_ad_height = 90;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
]]></content:encoded>
			<wfw:commentRss>http://coder.cl/2010/08/changes-in-my-ecb-hooks/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
<!-- This Quick Cache file was built for (  coder.cl/category/programming/emacs/feed/ ) in 0.37350 seconds, on Feb 7th, 2012 at 3:07 am UTC. -->
<!-- This Quick Cache file will automatically expire ( and be re-built automatically ) on Feb 7th, 2012 at 4:07 am UTC -->
