[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#17672: 24.4.50; [PATCH] python.el: Skeleton to insert import stateme
From: |
Matthias Meulien |
Subject: |
bug#17672: 24.4.50; [PATCH] python.el: Skeleton to insert import statements |
Date: |
Mon, 02 Jun 2014 23:02:31 +0200 |
The attach patch defines a skeleton to insert import statements in
Python mode.
>From 2342a864c8787f59039978196501a007ddb13e5c Mon Sep 17 00:00:00 2001
From: Matthias Meulien <orontee@gmail.com>
Date: Mon, 2 Jun 2014 22:37:07 +0200
Subject: [PATCH] python.el: Skeleton to insert import statements
---
lisp/progmodes/python.el | 18 +++++++++++++-----
1 file changed, 13 insertions(+), 5 deletions(-)
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
index 436442d..3d4d5a1 100644
--- a/lisp/progmodes/python.el
+++ b/lisp/progmodes/python.el
@@ -155,15 +155,16 @@
;; the shell completion in background so you should run
;; `python-shell-send-buffer' from time to time to get better results.
-;; Skeletons: 6 skeletons are provided for simple inserting of class,
-;; def, for, if, try and while. These skeletons are integrated with
-;; abbrev. If you have `abbrev-mode' activated and
+;; Skeletons: 7 skeletons are provided for simple inserting of class,
+;; def, for, import, if, try and while. These skeletons are
+;; integrated with abbrev. If you have `abbrev-mode' activated and
;; `python-skeleton-autoinsert' is set to t, then whenever you type
;; the name of any of those defined and hit SPC, they will be
;; automatically expanded. As an alternative you can use the defined
;; skeleton commands: `python-skeleton-class', `python-skeleton-def'
-;; `python-skeleton-for', `python-skeleton-if', `python-skeleton-try'
-;; and `python-skeleton-while'.
+;; `python-skeleton-for', `python-skeleton-import',
+;; `python-skeleton-if', `python-skeleton-try' and
+;; `python-skeleton-while'.
;; FFAP: You can find the filename for a given module when using ffap
;; out of the box. This feature needs an inferior python shell
@@ -253,6 +254,7 @@
(define-key map "\C-c\C-td" 'python-skeleton-def)
(define-key map "\C-c\C-tf" 'python-skeleton-for)
(define-key map "\C-c\C-ti" 'python-skeleton-if)
+ (define-key map "\C-c\C-tm" 'python-skeleton-import)
(define-key map "\C-c\C-tt" 'python-skeleton-try)
(define-key map "\C-c\C-tw" 'python-skeleton-while)
;; Shell interaction
@@ -2957,6 +2959,12 @@ The skeleton will be bound to python-skeleton-NAME."
> _ \n
'(python-skeleton--else) | ^)
+(python-skeleton-define import nil
+ "Import from module: "
+ "from " str & " " | -5
+ "import "
+ ("Identifier: " str ", ") -2 \n _)
+
(python-skeleton-define try nil
nil
"try:" \n
--
1.9.3
In GNU Emacs 24.4.50.1 (x86_64-unknown-linux-gnu, GTK+ Version 3.12.2)
of 2014-05-27 on choubidou
Windowing system distributor `The X.Org Foundation', version 11.0.11501000
Configured features:
XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK SOUND GPM DBUS GCONF GSETTINGS
NOTIFY ACL GNUTLS LIBXML2 FREETYPE M17N_FLT LIBOTF XFT ZLIB
Important settings:
value of $LC_COLLATE: C
value of $LANG: fr_FR.UTF-8
locale-coding-system: utf-8-unix
Major mode: Org
Minor modes in effect:
diff-auto-refine-mode: t
flyspell-mode: t
shell-dirtrack-mode: t
show-paren-mode: t
global-auto-complete-mode: t
global-semantic-mru-bookmark-mode: t
global-semanticdb-minor-mode: t
global-semantic-idle-scheduler-mode: t
semantic-mode: t
desktop-save-mode: t
auto-image-file-mode: t
electric-pair-mode: t
icomplete-mode: t
global-auto-revert-mode: t
auto-insert-mode: t
tooltip-mode: t
electric-indent-mode: t
mouse-wheel-mode: t
use-hard-newlines: t
file-name-shadow-mode: t
global-font-lock-mode: t
font-lock-mode: t
blink-cursor-mode: t
auto-composition-mode: t
auto-encryption-mode: t
auto-compression-mode: t
line-number-mode: t
auto-fill-function: org-auto-fill-function
transient-mark-mode: t
Recent input:
e m e n t s <return> M-p M-p M-p M-p C-b C-b C-b C-d
<return> C-x d <return> g q M-p C-b C-b ~ <return>
C-x d <return> g p p d x y <return> C-v C-n C-n C-n
C-n C-n C-n C-n C-n C-n C-n C-e <backspace> M-< C-_
C-_ C-x C-f C-x b p y t h <tab> <return> C-s i m p
o r t C-S-s C-s C-s C-s C-s C-s C-g <f9> <f9> <f9>
C-x b s h e l l <tab> 3 <tab> <return> C-x C-f 0 0
<tab> <return> C-n C-n C-x b p y t h o n <tab> <return>
M-g g 2 9 5 7 <return> C-e C-n C-n C-n C-n C-n C-n
C-n C-e <backspace> C-p C-e C-n C-n C-n C-e C-x C-s
C-x b * s h <tab> < <tab> 3 <tab> <return> M-p M-p
M-p SPC - - a m e n d <return> M-p M-p <return> C-x
C-f M-p <return> g C-_ C-x k <return> M-p M-p M-p M-p
M-p M-p M-p M-n <return> M-p M-p M-p <return> M-p M-p
M-p <return> C-x b 0 0 <tab> C-x C-f 0 0 <backspace>
<tab> <backspace> <tab> C-x C-f 0 0 1 <backspace> <tab>
<return> C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p
C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p M-< C-x
d <return> C-x 2 C-x d <M-backspace> <M-backspace>
p r o <tab> e m <tab> p a t <tab> <return> g C-x o
R M-p <return> g C-x o C-x o g n <return> C-x o C-x
b p y t h o <tab> <return> M-< C-n C-n C-n C-n M-f
C-n C-n <S-up> C-x o C-x o M-x r e p o r t SPC e m
<tab> <return>
Recent messages:
Omitting...
(Nothing to omit)
Omitting...
(Nothing to omit)
Move: 1 file
Omitting...
Omitted 7 lines.
Omitting...
Omitted 3 lines.
Mark set
Load-path shadows:
None found.
Features:
(shadow sort mail-extr gnus-msg gnus-art mm-uu mml2015 epg-config
mm-view mml-smime smime password-cache dig mailcap gnus-sum emacsbug
sendmail find-dired grep debug org-table org-id conf-mode diff-mode
add-log log-view pcvs-util descr-text hl-line rect dabbrev bookmark
tabify info-look pp derived pcase time-stamp semantic/edit diary-lib
diary-loaddefs reftex-dcr reftex reftex-vars tex-mode warnings inversion
semantic/bovine/c hideif semantic/bovine/c-by semantic/lex-spp
semantic/bovine/gcc semantic/analyze/refs cwarn sh-script executable
css-mode smie semantic/wisent/javascript-jv semantic/wisent/js-wy
semantic/java semantic/doc cap-words superword subword js json imenu
arc-mode archive-mode rst semantic/tag-write face-remap vc-dir ewoc vc
vc-dispatcher generic eieio-opt help-mode misearch multi-isearch
mule-util semantic/html sgml-mode semantic/bovine/make semantic/analyze
semantic/sort semantic/scope semantic/analyze/fcn
semantic/bovine/make-by semantic/bovine make-mode dired-aux avoid
flyspell ox-latex ox-icalendar ox-html ox-ascii ox-publish ox goto-addr
org-element org-rmail org-mhe org-irc org-info org-gnus org-docview
doc-view jka-compr image-mode org-bibtex bibtex org-bbdb org-w3m vc-git
semantic/tag-file semantic/db-file data-debug cedet-files
semantic/wisent/python semantic/decorate/include semantic/db-find
semantic/db-ref semantic/decorate/mode semantic/decorate pulse
semantic/dep semantic/wisent/python-wy semantic/wisent
semantic/wisent/wisent rx python ob-sh shell ob-plantuml paren
choubidou-custom cus-edit cus-start cus-load gnus-demon nntp gnus-group
gnus-undo gnus-start gnus-cloud nnimap nnmail mail-source tls utf7 netrc
parse-time gnus-spec gnus-win nnoo gnus-int gnus-range message rfc822
mml mml-sec mm-decode mm-bodies mm-encode mail-parse rfc2231 rfc2047
rfc2045 ietf-drums mailabbrev gmm-utils mailheader gnus gnus-ems
nnheader gnus-util mail-utils mm-util mail-prsvr wid-edit gnus-dired
dired-x dired org-capture org org-macro org-footnote org-pcomplete
pcomplete org-list org-faces org-entities noutline outline easy-mmode
org-version ob-emacs-lisp ob ob-tangle org-src ob-ref ob-lob ob-table
ob-keys ob-exp ob-comint ob-core ob-eval org-compat org-macs
org-loaddefs format-spec find-func cal-menu calendar cal-loaddefs
dictionary link connection irfc url-vars flymake-csslint php-mode etags
cc-langs speedbar sb-image dframe sql view thingatpt flymake-jslint
flymake-python-pyflakes flymake-easy advice help-fns flymake compile
comint hideshow skeleton find-file whitespace auto-complete edmacro
kmacro cl-macs popup cl minimap semantic/mru-bookmark ring
semantic/db-mode semantic/db gv eieio-base semantic/idle semantic/format
ezimage semantic/tag-ls semantic/find semantic/ctxt semantic/util-modes
semantic/util semantic semantic/tag semantic/lex semantic/fw mode-local
cedet ispell desktop frameset server woman man cl-loaddefs cl-lib
ansi-color image-file tar-mode saveplace elec-pair icomplete windmove
autorevert filenotify autoinsert cc-mode cc-fonts cc-guess cc-menus
cc-cmds cc-styles cc-align cc-engine cc-vars cc-defs generic-x
Django-doc-autoloads auto-complete-autoloads
color-theme-solarized-autoloads doctags-autoloads
flymake-csslint-autoloads flymake-jslint-autoloads
flymake-easy-autoloads gist-autoloads finder-inf gh-autoloads eieio
byte-opt bytecomp byte-compile cconv eieio-core info easymenu
gnuplot-autoloads graphviz-dot-mode-autoloads htmlize-autoloads
logito-autoloads php-mode-autoloads popup-autoloads
symbols-mode-autoloads package time-date tooltip electric uniquify
ediff-hook vc-hooks lisp-float-type mwheel x-win x-dnd tool-bar dnd
fontset image regexp-opt fringe tabulated-list newcomment lisp-mode
prog-mode register page menu-bar rfn-eshadow timer select scroll-bar
mouse jit-lock font-lock syntax facemenu font-core frame cham georgian
utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean
japanese hebrew greek romanian slovak czech european ethiopic indian
cyrillic chinese case-table epa-hook jka-cmpr-hook help simple abbrev
minibuffer nadvice loaddefs button faces cus-face macroexp files
text-properties overlay sha1 md5 base64 format env code-pages mule
custom widget hashtable-print-readable backquote make-network-process
dbusbind gfilenotify dynamic-setting system-font-setting
font-render-setting move-toolbar gtk x-toolkit x multi-tty emacs)
Memory information:
((conses 16 1100492 207925)
(symbols 48 63889 0)
(miscs 40 8990 837)
(strings 32 406285 30443)
(string-bytes 1 8349847)
(vectors 16 64126)
(vector-slots 8 1844234 141588)
(floats 8 408 778)
(intervals 56 43444 0)
(buffers 960 239)
(heap 1024 122508 19429))
- bug#17672: 24.4.50; [PATCH] python.el: Skeleton to insert import statements,
Matthias Meulien <=