[Python-modules-commits] [ropemacs] 01/07: Import ropemacs_0.8.orig.tar.gz

Arnaud Fontaine arnau at moszumanska.debian.org
Thu Dec 1 08:12:28 UTC 2016


This is an automated email from the git hooks/post-receive script.

arnau pushed a commit to branch master
in repository ropemacs.

commit deea2a951479ee78d5794ae96881db5468e7b152
Author: Arnaud Fontaine <arnaud.fontaine at nexedi.com>
Date:   Thu Dec 1 16:56:09 2016 +0900

    Import ropemacs_0.8.orig.tar.gz
---
 MANIFEST.in                         |   4 +-
 PKG-INFO                            |   8 ++-
 README.txt => README.rst            |  10 ++++
 docs/{done.txt => done.rst}         |   0
 docs/{ropemacs.txt => ropemacs.rst} |   2 +-
 docs/{todo.txt => todo.rst}         |   0
 ropemacs.egg-info/PKG-INFO          |   8 ++-
 ropemacs.egg-info/SOURCES.txt       |   8 +--
 ropemacs/__init__.py                | 114 ++++++++++++++++++++++++++++++++----
 setup.py                            |   7 ++-
 10 files changed, 136 insertions(+), 25 deletions(-)

diff --git a/MANIFEST.in b/MANIFEST.in
index c9965f0..1dbddca 100644
--- a/MANIFEST.in
+++ b/MANIFEST.in
@@ -1,5 +1,5 @@
-include README.txt COPYING setup.py MANIFEST.in CONTRIBUTORS
+include README.rst COPYING setup.py MANIFEST.in CONTRIBUTORS
 recursive-include ropemacs *.py
 recursive-include ropemode *.py
-recursive-include docs *.txt
+recursive-include docs *.rst
 recursive-include docs *.patch
diff --git a/PKG-INFO b/PKG-INFO
index aa779b3..65204fe 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,12 +1,18 @@
 Metadata-Version: 1.1
 Name: ropemacs
-Version: 0.7
+Version: 0.8
 Summary: An emacs mode for using rope python refactoring library
 Home-page: http://rope.sf.net/ropemacs.html
 Author: Ali Gholami Rudi
 Author-email: aligrudi at users.sourceforge.net
 License: GNU GPL
 Description: 
+        
+        **Note:** *Please note that this project has been moved to* `GitHub python-rope / ropemacs`_
+        
+        .. _GitHub python-rope / ropemacs: https://github.com/python-rope/ropemacs
+        
+        
         =========================
          ropemacs, rope in emacs
         =========================
diff --git a/README.txt b/README.rst
similarity index 97%
rename from README.txt
rename to README.rst
index 3c045ba..61e1acd 100644
--- a/README.txt
+++ b/README.rst
@@ -1,3 +1,9 @@
+
+**Note:** *Please note that this project has been moved to* `GitHub python-rope / ropemacs`_
+
+.. _GitHub python-rope / ropemacs: https://github.com/python-rope/ropemacs
+
+
 =========================
  ropemacs, rope in emacs
 =========================
@@ -137,6 +143,10 @@ files only.
 Code-Assist
 -----------
 
+Ropemacs integrates with ``completion-at-point`` (``C-M-i`` by
+default). Called once, it will insert the common prefix.  Called twice,
+it will pop up a buffer with all available completions.
+
 ``rope-code-assist`` command (``M-/`` by default) will let you select
 from a list of completions.  If prefixed (``C-u M-/``), ropemacs
 inserts the common prefix, automatically.  If a numeric argument is
diff --git a/docs/done.txt b/docs/done.rst
similarity index 100%
rename from docs/done.txt
rename to docs/done.rst
diff --git a/docs/ropemacs.txt b/docs/ropemacs.rst
similarity index 98%
rename from docs/ropemacs.txt
rename to docs/ropemacs.rst
index d80f15a..66cc14c 100644
--- a/docs/ropemacs.txt
+++ b/docs/ropemacs.rst
@@ -33,7 +33,7 @@ Features
 
 * Code-assists
 
-  * Code-completion
+  * Code completion
   * Goto definition
   * Show pydoc
   * Find occurrences
diff --git a/docs/todo.txt b/docs/todo.rst
similarity index 100%
rename from docs/todo.txt
rename to docs/todo.rst
diff --git a/ropemacs.egg-info/PKG-INFO b/ropemacs.egg-info/PKG-INFO
index aa779b3..65204fe 100644
--- a/ropemacs.egg-info/PKG-INFO
+++ b/ropemacs.egg-info/PKG-INFO
@@ -1,12 +1,18 @@
 Metadata-Version: 1.1
 Name: ropemacs
-Version: 0.7
+Version: 0.8
 Summary: An emacs mode for using rope python refactoring library
 Home-page: http://rope.sf.net/ropemacs.html
 Author: Ali Gholami Rudi
 Author-email: aligrudi at users.sourceforge.net
 License: GNU GPL
 Description: 
+        
+        **Note:** *Please note that this project has been moved to* `GitHub python-rope / ropemacs`_
+        
+        .. _GitHub python-rope / ropemacs: https://github.com/python-rope/ropemacs
+        
+        
         =========================
          ropemacs, rope in emacs
         =========================
diff --git a/ropemacs.egg-info/SOURCES.txt b/ropemacs.egg-info/SOURCES.txt
index 3f11356..2d6b16b 100644
--- a/ropemacs.egg-info/SOURCES.txt
+++ b/ropemacs.egg-info/SOURCES.txt
@@ -1,12 +1,12 @@
 CONTRIBUTORS
 COPYING
 MANIFEST.in
-README.txt
+README.rst
 setup.py
-docs/done.txt
+docs/done.rst
 docs/pymacs_signalrecursion.patch
-docs/ropemacs.txt
-docs/todo.txt
+docs/ropemacs.rst
+docs/todo.rst
 ropemacs/__init__.py
 ropemacs.egg-info/PKG-INFO
 ropemacs.egg-info/SOURCES.txt
diff --git a/ropemacs/__init__.py b/ropemacs/__init__.py
index 823dcbb..017e552 100644
--- a/ropemacs/__init__.py
+++ b/ropemacs/__init__.py
@@ -238,20 +238,47 @@ the rope-marker-ring")
     def prefix_value(self, prefix):
         return lisp.prefix_numeric_value(prefix)
 
+    def read_line_from_file(self, filename, lineno):
+        with open(filename) as f:
+            for i, line in enumerate(f):
+                if i+1 == lineno:
+                    return line
+
+        return "" # If lineno goes beyond the end of the file
+
     def show_occurrences(self, locations):
-        text = ['List of occurrences:', '']
-        for location in locations:
-            line = '%s : %s   %s %s' % (location.filename, location.lineno,
-                                        location.note, location.offset)
-            text.append(line)
-        text = '\n'.join(text) + '\n'
-        buffer = self._make_buffer('*rope-occurrences*', text, switch=False)
+        buffer = self._make_buffer('*rope-occurrences*', "", switch=False)
         lisp.set_buffer(buffer)
+        lisp.toggle_read_only(0)
+
+        trunc_length = len(lisp.rope_get_project_root())
+
+        lisp.insert('List of occurrences:\n')
+        for location in locations:
+            code_line = self.read_line_from_file(location.filename, location.lineno).rstrip()
+            filename = location.filename[trunc_length:]
+            lineno = str(location.lineno)
+            offset = str(location.offset)
+
+            lisp.insert(filename + ":" + lineno + ":" + code_line + " " + offset)
+
+            beginning = lisp.line_beginning_position()
+            end = beginning + len(filename)
+
+            lisp.add_text_properties(beginning, end, [lisp.face, lisp.button])
+            lisp.add_text_properties(beginning, end, [lisp.mouse_face, lisp.highlight,
+                                                      lisp.help_echo, "mouse-2: visit this file in other window"])
+
+            lisp.insert("\n")
+
         lisp.toggle_read_only(1)
+
         lisp.set(lisp["next-error-function"], lisp.rope_occurrences_next)
         lisp.local_set_key('\r', lisp.rope_occurrences_goto)
+        lisp.local_set_key((lisp.mouse_1,), lisp.rope_occurrences_goto)
         lisp.local_set_key('q', lisp.delete_window)
 
+
     def show_doc(self, docs, altview=False):
         use_minibuffer = not altview
         if self.get('separate_doc_buffer'):
@@ -365,15 +392,27 @@ def message(message):
     lisp.message(message.replace('%', '%%'))
 
 def occurrences_goto():
-    if lisp.line_number_at_pos() < 3:
-        lisp.forward_line(3 - lisp.line_number_at_pos())
+    if lisp.line_number_at_pos() < 1:
+        lisp.forward_line(1 - lisp.line_number_at_pos())
     lisp.end_of_line()
     end = lisp.point()
     lisp.beginning_of_line()
     line = lisp.buffer_substring_no_properties(lisp.point(), end)
     tokens = line.split()
-    if tokens:
-        filename = tokens[0]
+    semicolon_tokens = line.split(":")
+
+    project_root = lisp.rope_get_project_root()
+    if tokens and semicolon_tokens:
+        # Mark this line with an arrow
+        lisp('''
+        (remove-overlays (point-min) (point-max))
+            (overlay-put (make-overlay (line-beginning-position) (line-end-position))
+            'before-string
+            (propertize "A" 'display '(left-fringe right-triangle)))
+        ''')
+
+
+        filename = project_root + "/" + semicolon_tokens[0]
         offset = int(tokens[-1])
         resource = _interface._get_resource(filename)
         LispUtils().find_file(resource.real_path, other=True)
@@ -542,10 +581,59 @@ already opened.")
 """
 
 MINOR_MODE = """\
+(require 'thingatpt)
+
 (define-minor-mode ropemacs-mode
  "ropemacs, rope in emacs!" nil " Rope" ropemacs-local-keymap
-  :global nil)
-)
+  (if ropemacs-mode
+      (add-hook 'completion-at-point-functions 'ropemacs-completion-at-point nil t)
+    (remove-hook 'completion-at-point-functions 'ropemacs-completion-at-point t)))
+
+(defun ropemacs-completion-at-point ()
+  (unless (nth 8 (syntax-ppss))
+    (let ((bounds (or (bounds-of-thing-at-point 'symbol)
+                      (cons (point) (point)))))
+      (list (car bounds)
+            (cdr bounds)
+            'ropemacs--completion-table
+            :company-doc-buffer 'ropemacs--completion-doc-buffer
+            :company-location 'ropemacs--completion-location))))
+
+(defalias 'ropemacs--completion-table
+  (if (fboundp 'completion-table-with-cache)
+      (completion-table-with-cache #'ropemacs--completion-candidates)
+    (completion-table-dynamic #'ropemacs--completion-candidates)))
+
+(defun ropemacs--completion-candidates (prefix)
+  (mapcar (lambda (element) (concat prefix element))
+          (rope-completions)))
+
+(defun ropemacs--with-inserted (candidate fn)
+  (let ((inhibit-modification-hooks t)
+        (inhibit-point-motion-hooks t)
+        (modified-p (buffer-modified-p))
+        (beg (or (car (bounds-of-thing-at-point 'symbol)) (point)))
+        (pt (point)))
+     (insert (substring candidate (- pt beg)))
+     (unwind-protect
+         (funcall fn)
+       (delete-region pt (point))
+       (set-buffer-modified-p modified-p))))
+
+(defun ropemacs--completion-doc-buffer (candidate)
+  (let ((doc (ropemacs--with-inserted candidate #'rope-get-doc)))
+    (when doc
+      (with-current-buffer (get-buffer-create "*ropemacs-completion-doc*")
+        (erase-buffer)
+        (insert doc)
+        (goto-char (point-min))
+        (current-buffer)))))
+
+(defun ropemacs--completion-location (candidate)
+  (let ((location (ropemacs--with-inserted
+                   candidate #'rope-definition-location)))
+    (when location
+      (cons (elt location 0) (elt location 1)))))
 """
 
 shortcuts = [('M-/', 'rope-code-assist'),
diff --git a/setup.py b/setup.py
index 7f7e07c..b0fd36b 100644
--- a/setup.py
+++ b/setup.py
@@ -6,7 +6,7 @@ except ImportError:
     from distutils.core import setup
 
 
-classifiers=[
+classifiers = [
     'Development Status :: 4 - Beta',
     'Operating System :: OS Independent',
     'Environment :: X11 Applications',
@@ -19,13 +19,14 @@ classifiers=[
     'Topic :: Text Editors :: Emacs',
     'Topic :: Software Development']
 
+
 def get_long_description():
-    lines = open('README.txt').read().splitlines(False)
+    lines = open('README.rst').read().splitlines(False)
     end = lines.index('Setting Up')
     return '\n' + '\n'.join(lines[:end]) + '\n'
 
 setup(name='ropemacs',
-      version='0.7',
+      version='0.8',
       description='An emacs mode for using rope python refactoring library',
       long_description=get_long_description(),
       packages=['ropemacs'],

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/ropemacs.git



More information about the Python-modules-commits mailing list