[prev in list] [next in list] [prev in thread] [next in thread]
List: python-mode
Subject: [Python-mode] Fwd: Python mode function that I use
From: barry () python ! org (Barry Warsaw)
Date: 2008-11-21 20:16:51
Message-ID: 0BFB1E56-5FB6-48AE-8D50-DFF7C6BEF3F7 () python ! org
[Download RAW message or body]
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Begin forwarded message:
> From: "Yongsub Chung" <litdream1973 at users.sourceforge.net>
> Date: November 19, 2008 3:07:27 PM EST
> To: bwarsaw at users.sourceforge.net
> Subject: Python mode function that I use
> Message-Id: <E1L2tKh-000250-KT at g45xhf1.ch3.sourceforge.com>
>
>
> Message body follows:
>
> Hi. I have two python-mode elisp functions that can be
> useful. However, since I am very rough on elisp, I hope
> that someone can complete this more elegantly.
>
> Initially, its named after my namespace prefix, but
> hopefully, this becomes 'python-insert-import' and
> 'python-insert-from-import'.
>
> Thank you.
>
> Raymond
>
>
> ;;; code from here ;;;
>
> (defun ray-py-import (inc top)
> "Insert python import without changing buffer-location.
> For now, if '^import ' statement appears in the middle of
> the code,
> it is not smart to skip it. "
> (interactive "sImport name: \nsGoing to the top? (y/N) ")
> (if (or (string= top "y") (string= top "Y"))
> (save-excursion
> (beginning-of-buffer)
> (goto-char (re-search-forward "^import" nil t))
> (move-beginning-of-line nil)
> (insert-string "import " inc "\n"))
> (save-excursion
> (goto-char (re-search-backward "^import" nil t))
> (move-end-of-line nil)
> (insert-string "\n")
> (insert-string "import " inc))))
>
> (defun ray-py-from-import (from inc top)
> "Insert python 'from module import c1,c2' without changing
> buffer-location
> For now, if '^from ' statement appears in the middle of the
> code,
> it is not smart to skip it. "
> (interactive "sFrom module: \nsImport name: \nsGoing to
> the top? (y/N) ")
> (if (or (string= top "y") (string= top "Y"))
> (save-excursion
> (beginning-of-buffer)
> (goto-char (re-search-forward "^from " nil t))
> (move-beginning-of-line nil)
> (insert-string "from " from " import " inc "\n"))
> (save-excursion
> (goto-char (re-search-backward "^from " nil t))
> (move-end-of-line nil)
> (insert-string "\n")
> (insert-string "from " from " import " inc ))))
>
>
> --
> This message has been sent to you, a registered SourceForge.net user,
> by another site user, through the SourceForge.net site. This message
> has been delivered to your SourceForge.net mail alias. You may reply
> to this message using the "Reply" feature of your email client, or
> using the messaging facility of SourceForge.net at:
> https://sourceforge.net/sendmessage.php?touser=2294541
>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Darwin)
iQCVAwUBSScXM3EjvBPtnXfVAQIDJwP/YfThDf8WWo9xyZGW7gCShQBMjpGcxptM
+FEQE7Wu4z6CWbFeLSHEMbhUABEOjyOam2CYvmY5Oy1u2kk6mWlDbvjXNri7mhsQ
8E5PiEQcYmS5ZMs4ObLNk7jbdGElV18j9znso3Kn37kVdcb764Cop/cRLvi2/taN
XyboXjebFrM=
=6A1e
-----END PGP SIGNATURE-----
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic