From urs.fleisch at gmail.com Sun Jul 1 15:04:33 2012 From: urs.fleisch at gmail.com (Urs Fleisch) Date: Sun, 1 Jul 2012 15:04:33 +0200 Subject: [Python-mode] [PATCH] Improved pycomplete Message-ID: Hi, Here is a little patch, which fixes the following problems in pycomplete: py-find-global-imports(): Support dot in "from ... import" statements, e.g. "from PyQt4.QtGui import QMainWindow". get_all_completions(): Return an empty list when no symbol is found (e.g. when trying to complete "[].ap"). Then I have integrated a few changes ported from the current version in http://www.rwdev.eu/articles/emacspyeng: py-complete(), get_all_completions(): Additional except statements when calling eval, exec and __import__, checks if symbol is empty. pycomplete(): Change to directory where file is, so that relative imports also work when file is not in the current directory of the Python interpreter. Is it OK to send patches like this, or would you prefer an attachment or a bzr merge request? Regards, Urs === modified file 'completion/pycomplete.el' --- completion/pycomplete.el 2012-05-10 11:19:31 +0000 +++ completion/pycomplete.el 2012-07-01 11:42:53 +0000 @@ -49,7 +49,7 @@ (goto-char (point-min)) (setq imports nil) (while (re-search-forward - "^\\(import \\|from \\([A-Za-z_][A-Za-z_0-9]*\\) import \\).*" + "^\\(import \\|from \\([A-Za-z_\\.][A-Za-z_0-9\\.]*\\) import \\).*" nil t) (setq imports (append imports (list (buffer-substring @@ -62,7 +62,7 @@ (let* ((pymacs-forget-mutability t) (symbol (py-symbol-near-point)) (completions - (pycomplete-pycomplete symbol + (pycomplete-pycomplete symbol (buffer-file-name) (py-find-global-imports)))) (cond ((null completions) ; no matching symbol (message "Can't find completion for \"%s\"" symbol) === modified file 'completion/pycomplete.py' --- completion/pycomplete.py 2012-05-10 11:19:31 +0000 +++ completion/pycomplete.py 2012-07-01 12:12:23 +0000 @@ -59,6 +59,8 @@ exec stmt in globals(), locald except TypeError: raise TypeError, "invalid type: %s" % stmt + except Exception: + continue dots = s.split(".") if not s or len(dots) == 1: @@ -77,6 +79,8 @@ sym = None for i in range(1, len(dots)): s = ".".join(dots[:i]) + if not s: + continue try: sym = eval(s, globals(), locald) except NameError: @@ -84,11 +88,23 @@ sym = __import__(s, globals(), locald, []) except ImportError: return [] + except AttributeError: + try: + sym = __import__(s, globals(), locald, []) + except ImportError: + pass if sym is not None: s = dots[-1] return [k for k in dir(sym) if k.startswith(s)] - -def pycomplete(s, imports=None): + return [] + +def pycomplete(s, fname=None, imports=None): + if not s: + return '' + # changes to where the file is + if fname: + os.chdir(os.path.dirname(fname)) + completions = get_all_completions(s, imports) if len(completions) == 0: return None From andreas.roehler at online.de Sun Jul 1 15:49:24 2012 From: andreas.roehler at online.de (=?ISO-8859-1?Q?Andreas_R=F6hler?=) Date: Sun, 01 Jul 2012 15:49:24 +0200 Subject: [Python-mode] [PATCH] Improved pycomplete In-Reply-To: References: Message-ID: <4FF05564.6090605@online.de> Am 01.07.2012 15:04, schrieb Urs Fleisch: > Hi, > > Here is a little patch, which fixes the following problems in pycomplete: > > py-find-global-imports(): Support dot in "from ... import" statements, > e.g. "from PyQt4.QtGui import QMainWindow". > > get_all_completions(): Return an empty list when no symbol is found > (e.g. when trying to complete "[].ap"). > > Then I have integrated a few changes ported from the current version > in http://www.rwdev.eu/articles/emacspyeng: > > py-complete(), get_all_completions(): Additional except statements > when calling eval, exec and __import__, checks if symbol is empty. > > pycomplete(): Change to directory where file is, so that relative > imports also work when file is not in the current directory of the > Python interpreter. > > Is it OK to send patches like this, or would you prefer an attachment > or a bzr merge request? > > Regards, > Urs Hi, thanks a lot for the patch. If you might open a ticket at https://bugs.launchpad.net/python-mode for it, the patch attached, that would help still, as it's easier to refer. Alternatively a branch and merge request are fine also. Andreas > > === modified file 'completion/pycomplete.el' > --- completion/pycomplete.el 2012-05-10 11:19:31 +0000 > +++ completion/pycomplete.el 2012-07-01 11:42:53 +0000 > @@ -49,7 +49,7 @@ > (goto-char (point-min)) > (setq imports nil) > (while (re-search-forward > - "^\\(import \\|from \\([A-Za-z_][A-Za-z_0-9]*\\) import \\).*" > + "^\\(import \\|from \\([A-Za-z_\\.][A-Za-z_0-9\\.]*\\) import \\).*" > nil t) > (setq imports (append imports > (list (buffer-substring > @@ -62,7 +62,7 @@ > (let* ((pymacs-forget-mutability t) > (symbol (py-symbol-near-point)) > (completions > - (pycomplete-pycomplete symbol > + (pycomplete-pycomplete symbol (buffer-file-name) > (py-find-global-imports)))) > (cond ((null completions) ; no matching symbol > (message "Can't find completion for \"%s\"" symbol) > > === modified file 'completion/pycomplete.py' > --- completion/pycomplete.py 2012-05-10 11:19:31 +0000 > +++ completion/pycomplete.py 2012-07-01 12:12:23 +0000 > @@ -59,6 +59,8 @@ > exec stmt in globals(), locald > except TypeError: > raise TypeError, "invalid type: %s" % stmt > + except Exception: > + continue > > dots = s.split(".") > if not s or len(dots) == 1: > @@ -77,6 +79,8 @@ > sym = None > for i in range(1, len(dots)): > s = ".".join(dots[:i]) > + if not s: > + continue > try: > sym = eval(s, globals(), locald) > except NameError: > @@ -84,11 +88,23 @@ > sym = __import__(s, globals(), locald, []) > except ImportError: > return [] > + except AttributeError: > + try: > + sym = __import__(s, globals(), locald, []) > + except ImportError: > + pass > if sym is not None: > s = dots[-1] > return [k for k in dir(sym) if k.startswith(s)] > - > -def pycomplete(s, imports=None): > + return [] > + > +def pycomplete(s, fname=None, imports=None): > + if not s: > + return '' > + # changes to where the file is > + if fname: > + os.chdir(os.path.dirname(fname)) > + > completions = get_all_completions(s, imports) > if len(completions) == 0: > return None > _______________________________________________ > Python-mode mailing list > Python-mode at python.org > http://mail.python.org/mailman/listinfo/python-mode > From urs.fleisch at gmail.com Sun Jul 1 16:19:48 2012 From: urs.fleisch at gmail.com (Urs Fleisch) Date: Sun, 1 Jul 2012 16:19:48 +0200 Subject: [Python-mode] [PATCH] Improved pycomplete In-Reply-To: <4FF05564.6090605@online.de> References: <4FF05564.6090605@online.de> Message-ID: <20120701161948.debcab7e54645a984800c33c@gmail.com> Hi, > If you might open a ticket at > > https://bugs.launchpad.net/python-mode > > for it, the patch attached, that would help still, as it's easier to refer. OK, I have opened a bug: https://bugs.launchpad.net/python-mode/+bug/1019791. I have another little patch, not related to a bug, rather an improvement. It provides functions py-complete-define-ac-source(), py-complete-define-company-completion() to integrate pycomplete into auto-complete or company, so that the completions are displayed in a nice popup. Regards, Urs === modified file 'completion/pycomplete.el' --- completion/pycomplete.el 2012-07-01 13:05:48 +0000 +++ completion/pycomplete.el 2012-07-01 13:21:44 +0000 @@ -78,4 +78,50 @@ (display-completion-list completions)) (message "Making completion list...%s" "done"))))) +(defun py-complete-completions () + "get possible completions for current statement" + (pycomplete-get-all-completions + (py-symbol-near-point) + (py-find-global-imports))) + +(defun py-complete-define-ac-source () + "Define ac-source-pycomplete to be used with auto-complete. + +The ac-source can be enabled solely using +(setq ac-sources '(ac-source-pycomplete)) +or before the other sources using +(add-to-list 'ac-sources 'ac-source-pycomplete)." + (require 'auto-complete) + (ac-define-source pycomplete + '((candidates . py-complete-completions)))) + +(defun py-complete-define-company-completion () + "Define company-pycomplete function to be used with company. + +The function can be enabled using +(setq company-backends '((company-pycomplete)))." + (require 'company) + (defun company-pycomplete--grab-symbol () + (let ((symbol (company-grab-symbol))) + (when symbol + (cons symbol + (save-excursion + (let ((pos (point))) + (goto-char (- (point) (length symbol))) + (while (eq (char-before) ?.) + (goto-char (1- (point))) + (skip-syntax-backward "w_")) + (- pos (point)))))))) + (defun company-pycomplete (command &optional arg &rest ignored) + "A `company-mode' completion back-end for pycomplete." + (interactive (list 'interactive)) + (case command + ('interactive (company-begin-backend 'company-pycomplete)) + ('prefix (and (derived-mode-p 'python-mode) + buffer-file-name + (not (company-in-string-or-comment)) + (company-pycomplete--grab-symbol))) + ('candidates (py-complete-completions)))) + ) + (provide 'pycomplete) From andreas.roehler at online.de Sun Jul 1 21:06:49 2012 From: andreas.roehler at online.de (=?ISO-8859-1?Q?Andreas_R=F6hler?=) Date: Sun, 01 Jul 2012 21:06:49 +0200 Subject: [Python-mode] [PATCH] Improved pycomplete In-Reply-To: <20120701161948.debcab7e54645a984800c33c@gmail.com> References: <4FF05564.6090605@online.de> <20120701161948.debcab7e54645a984800c33c@gmail.com> Message-ID: <4FF09FC9.4080509@online.de> Am 01.07.2012 16:19, schrieb Urs Fleisch: > Hi, > >> If you might open a ticket at >> >> https://bugs.launchpad.net/python-mode >> >> for it, the patch attached, that would help still, as it's easier to refer. > > OK, I have opened a bug: https://bugs.launchpad.net/python-mode/+bug/1019791. > > I have another little patch, not related to a bug, rather an improvement. > It provides functions py-complete-define-ac-source(), py-complete-define-company-completion() to integrate pycomplete into auto-complete or company, so that the completions are displayed in a nice popup. > > Regards, > Urs > Hi, thanks a lot, that's quite interesting. If your time permit, please make a now branch related to company. Best, Andreas As we have several options to realise auto-completion, > === modified file 'completion/pycomplete.el' > --- completion/pycomplete.el 2012-07-01 13:05:48 +0000 > +++ completion/pycomplete.el 2012-07-01 13:21:44 +0000 > @@ -78,4 +78,50 @@ > (display-completion-list completions)) > (message "Making completion list...%s" "done"))))) > > +(defun py-complete-completions () > + "get possible completions for current statement" > + (pycomplete-get-all-completions > + (py-symbol-near-point) > + (py-find-global-imports))) > + > +(defun py-complete-define-ac-source () > + "Define ac-source-pycomplete to be used with auto-complete. > + > +The ac-source can be enabled solely using > +(setq ac-sources '(ac-source-pycomplete)) > +or before the other sources using > +(add-to-list 'ac-sources 'ac-source-pycomplete)." > + (require 'auto-complete) > + (ac-define-source pycomplete > + '((candidates . py-complete-completions)))) > + > +(defun py-complete-define-company-completion () > + "Define company-pycomplete function to be used with company. > + > +The function can be enabled using > +(setq company-backends '((company-pycomplete)))." > + (require 'company) > + (defun company-pycomplete--grab-symbol () > + (let ((symbol (company-grab-symbol))) > + (when symbol > + (cons symbol > + (save-excursion > + (let ((pos (point))) > + (goto-char (- (point) (length symbol))) > + (while (eq (char-before) ?.) > + (goto-char (1- (point))) > + (skip-syntax-backward "w_")) > + (- pos (point)))))))) > + (defun company-pycomplete (command &optional arg &rest ignored) > + "A `company-mode' completion back-end for pycomplete." > + (interactive (list 'interactive)) > + (case command > + ('interactive (company-begin-backend 'company-pycomplete)) > + ('prefix (and (derived-mode-p 'python-mode) > + buffer-file-name > + (not (company-in-string-or-comment)) > + (company-pycomplete--grab-symbol))) > + ('candidates (py-complete-completions)))) > + ) > + > (provide 'pycomplete) > > From andreas.roehler at online.de Mon Jul 2 14:15:53 2012 From: andreas.roehler at online.de (=?ISO-8859-1?Q?Andreas_R=F6hler?=) Date: Mon, 02 Jul 2012 14:15:53 +0200 Subject: [Python-mode] [PATCH] Improved pycomplete In-Reply-To: <20120701161948.debcab7e54645a984800c33c@gmail.com> References: <4FF05564.6090605@online.de> <20120701161948.debcab7e54645a984800c33c@gmail.com> Message-ID: <4FF190F9.5000901@online.de> > > I have another little patch, Hi Urs, thinking meanwhile it might be worth a separate file, as it relies at company. You will be aware of M-x auto-insert. Thanks a lot, Andreas not related to a bug, rather an improvement. > It provides functions py-complete-define-ac-source(), py-complete-define-company-completion() to integrate pycomplete into auto-complete or company, so that the completions are displayed in a nice popup. > > Regards, > Urs > > === modified file 'completion/pycomplete.el' > --- completion/pycomplete.el 2012-07-01 13:05:48 +0000 > +++ completion/pycomplete.el 2012-07-01 13:21:44 +0000 > @@ -78,4 +78,50 @@ > (display-completion-list completions)) > (message "Making completion list...%s" "done"))))) > > +(defun py-complete-completions () > + "get possible completions for current statement" > + (pycomplete-get-all-completions > + (py-symbol-near-point) > + (py-find-global-imports))) > + > +(defun py-complete-define-ac-source () > + "Define ac-source-pycomplete to be used with auto-complete. > + > +The ac-source can be enabled solely using > +(setq ac-sources '(ac-source-pycomplete)) > +or before the other sources using > +(add-to-list 'ac-sources 'ac-source-pycomplete)." > + (require 'auto-complete) > + (ac-define-source pycomplete > + '((candidates . py-complete-completions)))) > + > +(defun py-complete-define-company-completion () > + "Define company-pycomplete function to be used with company. > + > +The function can be enabled using > +(setq company-backends '((company-pycomplete)))." > + (require 'company) > + (defun company-pycomplete--grab-symbol () > + (let ((symbol (company-grab-symbol))) > + (when symbol > + (cons symbol > + (save-excursion > + (let ((pos (point))) > + (goto-char (- (point) (length symbol))) > + (while (eq (char-before) ?.) > + (goto-char (1- (point))) > + (skip-syntax-backward "w_")) > + (- pos (point)))))))) > + (defun company-pycomplete (command &optional arg &rest ignored) > + "A `company-mode' completion back-end for pycomplete." > + (interactive (list 'interactive)) > + (case command > + ('interactive (company-begin-backend 'company-pycomplete)) > + ('prefix (and (derived-mode-p 'python-mode) > + buffer-file-name > + (not (company-in-string-or-comment)) > + (company-pycomplete--grab-symbol))) > + ('candidates (py-complete-completions)))) > + ) > + > (provide 'pycomplete) > > From urs.fleisch at gmail.com Mon Jul 2 21:18:18 2012 From: urs.fleisch at gmail.com (Urs Fleisch) Date: Mon, 2 Jul 2012 21:18:18 +0200 Subject: [Python-mode] [PATCH] Improved pycomplete In-Reply-To: <4FF190F9.5000901@online.de> References: <4FF05564.6090605@online.de> <20120701161948.debcab7e54645a984800c33c@gmail.com> <4FF190F9.5000901@online.de> Message-ID: <20120702211818.56b5990cb20ad33a804ee055@gmail.com> Hi Andreas, I have put the code for company and auto-complete into separate files. Regards, Urs === added file 'completion/auto-complete-pycomplete.el' --- completion/auto-complete-pycomplete.el 1970-01-01 00:00:00 +0000 +++ completion/auto-complete-pycomplete.el 2012-07-02 19:14:02 +0000 @@ -0,0 +1,37 @@ +;;; auto-complete-pycomplete.el --- an auto-complete source for pycomplete.el + +;; Copyright (C) 2012 Urs Fleisch + +;; Author: Urs Fleisch +;; Keywords: languages, processes, python, oop + +;; This program is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with this program. If not, see . + +;;; Commentary: + +;; The ac-source can be enabled solely using +;; (setq ac-sources '(ac-source-pycomplete)) +;; or before the other sources using +;; (add-to-list 'ac-sources 'ac-source-pycomplete). + +;;; Code: + +(require 'pycomplete) +(require 'auto-complete) + +(ac-define-source pycomplete + '((candidates . py-complete-completions))) + +(provide 'auto-complete-pycomplete) +;;; auto-complete-pycomplete.el ends here === added file 'completion/company-pycomplete.el' --- completion/company-pycomplete.el 1970-01-01 00:00:00 +0000 +++ completion/company-pycomplete.el 2012-07-02 19:10:20 +0000 @@ -0,0 +1,55 @@ +;;; company-pycomplete.el --- a company-mode completion back-end for pycomplete.el + +;; Copyright (C) 2012 Urs Fleisch + +;; Author: Urs Fleisch +;; Keywords: languages, processes, python, oop + +;; This program is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with this program. If not, see . + +;;; Commentary: + +;; The backend can be enabled using +;; (setq company-backends '((company-pycomplete))) + +;;; Code: + +(require 'pycomplete) +(require 'company) + +(defun company-pycomplete--grab-symbol () + ;; stolen from company-pysmell--grab-symbol + (let ((symbol (company-grab-symbol))) + (when symbol + (cons symbol + (save-excursion + (let ((pos (point))) + (goto-char (- (point) (length symbol))) + (while (eq (char-before) ?.) + (goto-char (1- (point))) + (skip-syntax-backward "w_")) + (- pos (point)))))))) + +(defun company-pycomplete (command &optional arg &rest ignored) + "A `company-mode' completion back-end for pycomplete." + (interactive (list 'interactive)) + (case command + ('interactive (company-begin-backend 'company-pycomplete)) + ('prefix (and (derived-mode-p 'python-mode) + (not (company-in-string-or-comment)) + (company-pycomplete--grab-symbol))) + ('candidates (py-complete-completions)))) + +(provide 'company-pycomplete) +;;; company-pycomplete.el ends here === modified file 'completion/pycomplete.el' --- completion/pycomplete.el 2012-07-01 13:05:48 +0000 +++ completion/pycomplete.el 2012-07-02 18:43:06 +0000 @@ -78,4 +78,10 @@ (display-completion-list completions)) (message "Making completion list...%s" "done"))))) +(defun py-complete-completions () + "get possible completions for current statement" + (pycomplete-get-all-completions + (py-symbol-near-point) + (py-find-global-imports))) + (provide 'pycomplete) From andreas.roehler at online.de Mon Jul 2 21:19:01 2012 From: andreas.roehler at online.de (=?ISO-8859-1?Q?Andreas_R=F6hler?=) Date: Mon, 02 Jul 2012 21:19:01 +0200 Subject: [Python-mode] [PATCH] Improved pycomplete In-Reply-To: <20120702211818.56b5990cb20ad33a804ee055@gmail.com> References: <4FF05564.6090605@online.de> <20120701161948.debcab7e54645a984800c33c@gmail.com> <4FF190F9.5000901@online.de> <20120702211818.56b5990cb20ad33a804ee055@gmail.com> Message-ID: <4FF1F425.5090702@online.de> Am 02.07.2012 21:18, schrieb Urs Fleisch: > Hi Andreas, > > I have put the code for company and auto-complete into separate files. > > Regards, > Urs > Thanks, Urs, BTW next time, please make another step and send patches as an attachment on per-file basis. Thus I may read in them simply with command `patch' Cheers, Andreas > === added file 'completion/auto-complete-pycomplete.el' > --- completion/auto-complete-pycomplete.el 1970-01-01 00:00:00 +0000 > +++ completion/auto-complete-pycomplete.el 2012-07-02 19:14:02 +0000 > @@ -0,0 +1,37 @@ > +;;; auto-complete-pycomplete.el --- an auto-complete source for pycomplete.el > + > +;; Copyright (C) 2012 Urs Fleisch > + > +;; Author: Urs Fleisch > +;; Keywords: languages, processes, python, oop > + > +;; This program is free software; you can redistribute it and/or modify > +;; it under the terms of the GNU General Public License as published by > +;; the Free Software Foundation, either version 3 of the License, or > +;; (at your option) any later version. > + > +;; This program is distributed in the hope that it will be useful, > +;; but WITHOUT ANY WARRANTY; without even the implied warranty of > +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > +;; GNU General Public License for more details. > + > +;; You should have received a copy of the GNU General Public License > +;; along with this program. If not, see . > + > +;;; Commentary: > + > +;; The ac-source can be enabled solely using > +;; (setq ac-sources '(ac-source-pycomplete)) > +;; or before the other sources using > +;; (add-to-list 'ac-sources 'ac-source-pycomplete). > + > +;;; Code: > + > +(require 'pycomplete) > +(require 'auto-complete) > + > +(ac-define-source pycomplete > + '((candidates . py-complete-completions))) > + > +(provide 'auto-complete-pycomplete) > +;;; auto-complete-pycomplete.el ends here > > === added file 'completion/company-pycomplete.el' > --- completion/company-pycomplete.el 1970-01-01 00:00:00 +0000 > +++ completion/company-pycomplete.el 2012-07-02 19:10:20 +0000 > @@ -0,0 +1,55 @@ > +;;; company-pycomplete.el --- a company-mode completion back-end for pycomplete.el > + > +;; Copyright (C) 2012 Urs Fleisch > + > +;; Author: Urs Fleisch > +;; Keywords: languages, processes, python, oop > + > +;; This program is free software; you can redistribute it and/or modify > +;; it under the terms of the GNU General Public License as published by > +;; the Free Software Foundation, either version 3 of the License, or > +;; (at your option) any later version. > + > +;; This program is distributed in the hope that it will be useful, > +;; but WITHOUT ANY WARRANTY; without even the implied warranty of > +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > +;; GNU General Public License for more details. > + > +;; You should have received a copy of the GNU General Public License > +;; along with this program. If not, see . > + > +;;; Commentary: > + > +;; The backend can be enabled using > +;; (setq company-backends '((company-pycomplete))) > + > +;;; Code: > + > +(require 'pycomplete) > +(require 'company) > + > +(defun company-pycomplete--grab-symbol () > + ;; stolen from company-pysmell--grab-symbol > + (let ((symbol (company-grab-symbol))) > + (when symbol > + (cons symbol > + (save-excursion > + (let ((pos (point))) > + (goto-char (- (point) (length symbol))) > + (while (eq (char-before) ?.) > + (goto-char (1- (point))) > + (skip-syntax-backward "w_")) > + (- pos (point)))))))) > + > +(defun company-pycomplete (command &optional arg &rest ignored) > + "A `company-mode' completion back-end for pycomplete." > + (interactive (list 'interactive)) > + (case command > + ('interactive (company-begin-backend 'company-pycomplete)) > + ('prefix (and (derived-mode-p 'python-mode) > + (not (company-in-string-or-comment)) > + (company-pycomplete--grab-symbol))) > + ('candidates (py-complete-completions)))) > + > +(provide 'company-pycomplete) > +;;; company-pycomplete.el ends here > > === modified file 'completion/pycomplete.el' > --- completion/pycomplete.el 2012-07-01 13:05:48 +0000 > +++ completion/pycomplete.el 2012-07-02 18:43:06 +0000 > @@ -78,4 +78,10 @@ > (display-completion-list completions)) > (message "Making completion list...%s" "done"))))) > > +(defun py-complete-completions () > + "get possible completions for current statement" > + (pycomplete-get-all-completions > + (py-symbol-near-point) > + (py-find-global-imports))) > + > (provide 'pycomplete) > > From urs.fleisch at gmail.com Wed Jul 4 16:56:38 2012 From: urs.fleisch at gmail.com (Urs Fleisch) Date: Wed, 4 Jul 2012 16:56:38 +0200 Subject: [Python-mode] [PATCH] Improved pycomplete In-Reply-To: <4FF1F425.5090702@online.de> References: <4FF05564.6090605@online.de> <20120701161948.debcab7e54645a984800c33c@gmail.com> <4FF190F9.5000901@online.de> <20120702211818.56b5990cb20ad33a804ee055@gmail.com> <4FF1F425.5090702@online.de> Message-ID: Hi Andreas, I have another patch: https://bugs.launchpad.net/python-mode/+bug/1020973 > BTW next time, please make another step and send patches as an attachment on > per-file basis. > Thus I may read in them simply with command `patch' I will attach patch files from now on. However, it is also possible to use the 'patch' command with a single diff containing changes for multiple files. The bug mentioned above concerns the "Help on symbol" function. The pycomplete from http://www.rwdev.eu/articles/emacspyeng contains a function to display python help using Pymacs, so it does not create a temporary python file and start its own subprocess like py-describe-symbol() and it feels much smoother. There is also a function which displays the signature of a python function, which is quite useful. I have attached a .diff file and also a merge request (the file with .patch extension) from a "components-python-mode" branch. It also includes my auto-complete/company changes and the bug fix mentioned above. What is the best way to contribute if I want to improve the completion further? Regards, Urs -------------- next part -------------- A non-text attachment was scrubbed... Name: pycomplete_doc_signature.diff Type: application/octet-stream Size: 7378 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: pycomplete_1531_1533_bzrsend.patch Type: application/octet-stream Size: 19114 bytes Desc: not available URL: From andreas.roehler at online.de Fri Jul 6 20:35:27 2012 From: andreas.roehler at online.de (=?ISO-8859-15?Q?Andreas_R=F6hler?=) Date: Fri, 06 Jul 2012 20:35:27 +0200 Subject: [Python-mode] freezed branches Message-ID: <4FF72FEF.4080108@online.de> Hi Barry, in case a distro shipping python-mode.el declares a freeze, we may meet that creating a freezed branch mentioning that distro or release name Then developing might go on in trunk, whilst the freeze is honoured. WDYT? Andreas From barry at python.org Fri Jul 6 21:25:59 2012 From: barry at python.org (Barry Warsaw) Date: Fri, 6 Jul 2012 15:25:59 -0400 Subject: [Python-mode] freezed branches In-Reply-To: <4FF72FEF.4080108@online.de> References: <4FF72FEF.4080108@online.de> Message-ID: <20120706152559.060893f1@resist.wooz.org> On Jul 06, 2012, at 08:35 PM, Andreas R?hler wrote: >in case a distro shipping python-mode.el declares a freeze, we may meet that >creating a freezed branch mentioning that distro or release name > >Then developing might go on in trunk, whilst the freeze is honoured. I probably wouldn't tie a branch to any specific distro. That's setting a bad precedence that could potentially add lots of extra work if other distros want the same treatment. Instead, you could tie branches to python-mode version series. E.g. You could branch for 6.0.x and then 6.1.x would be developed on trunk. Just be cautious about any bug fixes you backport to the 6.0.x branch and don't backport any new features. It would then be up to distro's package maintainer to cherry pick fixes from the appropriate branch during the lifetime of the stable distro release. Cheers, -Barry -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: not available URL: From andreas.roehler at online.de Fri Jul 6 22:10:53 2012 From: andreas.roehler at online.de (=?UTF-8?B?QW5kcmVhcyBSw7ZobGVy?=) Date: Fri, 06 Jul 2012 22:10:53 +0200 Subject: [Python-mode] freezed branches In-Reply-To: <20120706152559.060893f1@resist.wooz.org> References: <4FF72FEF.4080108@online.de> <20120706152559.060893f1@resist.wooz.org> Message-ID: <4FF7464D.2070203@online.de> Am 06.07.2012 21:25, schrieb Barry Warsaw: > On Jul 06, 2012, at 08:35 PM, Andreas R?hler wrote: > >> in case a distro shipping python-mode.el declares a freeze, we may meet that >> creating a freezed branch mentioning that distro or release name >> >> Then developing might go on in trunk, whilst the freeze is honoured. > > I probably wouldn't tie a branch to any specific distro. That's setting a bad > precedence that could potentially add lots of extra work if other distros want > the same treatment. > > Instead, you could tie branches to python-mode version series. E.g. You could > branch for 6.0.x and then 6.1.x would be developed on trunk. Just be cautious > about any bug fixes you backport to the 6.0.x branch and don't backport any > new features. It would then be up to distro's package maintainer to > cherry pick fixes from the appropriate branch during the lifetime of the > stable distro release. > > Cheers, > -Barry > okay, thanks, Andreas From andreas.roehler at online.de Sat Jul 14 13:06:16 2012 From: andreas.roehler at online.de (=?UTF-8?B?QW5kcmVhcyBSw7ZobGVy?=) Date: Sat, 14 Jul 2012 13:06:16 +0200 Subject: [Python-mode] [Branch ~ufleisch/python-mode/improve-completion] Rev 1542: Support completion of list, dict and str literals. In-Reply-To: <20120714103710.1134.45269.launchpad@ackee.canonical.com> References: <20120714103710.1134.45269.launchpad@ackee.canonical.com> Message-ID: <500152A8.6010600@online.de> Am 14.07.2012 12:37, schrieb noreply at launchpad.net: > - (symbol (py-symbol-near-point)) > + (symbol (py-complete-enhanced-symbol-before-point)) Hi Urs, some reflections on naming - cc to Barry and python-mode list, as is seems of general interest and opinions may differ. - prefix py-complete Suggest to use "complete" as part of a name only, if completion is really at stake. - replacing symbols in case, you drop/replace are function completely as with `py-symbol-near-point' please take in consideration, it might be used by third party stuff. Please be as conservative as possible, rather keep the symbol with new body if needed. With great joy seeing python-mode proceeding, Andreas From andreas.roehler at online.de Sat Jul 21 09:00:09 2012 From: andreas.roehler at online.de (=?ISO-8859-15?Q?Andreas_R=F6hler?=) Date: Sat, 21 Jul 2012 09:00:09 +0200 Subject: [Python-mode] NEWS file Message-ID: <500A5379.609@online.de> Hi, when introducing extensions, please consider updating NEWS file also. It serves as a kind of changelog, base of announcements. thanks all, Andreas