diff options
| author | Eli Zaretskii | 2013-04-19 11:39:24 +0300 |
|---|---|---|
| committer | Eli Zaretskii | 2013-04-19 11:39:24 +0300 |
| commit | 4cf86a2fa737296d26e8a02338e2bf6f26e1133a (patch) | |
| tree | 094502cb2926db798570e62d32c680b2ce72b6c2 | |
| parent | f60f289656d815827a492150f2e564dd081967f8 (diff) | |
| parent | 7d6883367a54b4eee342aa861ef73e4191151ef0 (diff) | |
| download | emacs-4cf86a2fa737296d26e8a02338e2bf6f26e1133a.tar.gz emacs-4cf86a2fa737296d26e8a02338e2bf6f26e1133a.zip | |
Merge from trunk.
| -rw-r--r-- | ChangeLog | 4 | ||||
| -rw-r--r-- | configure.ac | 25 | ||||
| -rw-r--r-- | lisp/ChangeLog | 27 | ||||
| -rw-r--r-- | lisp/bookmark.el | 27 | ||||
| -rw-r--r-- | lisp/progmodes/python.el | 234 | ||||
| -rw-r--r-- | lisp/vc/vc-dispatcher.el | 4 | ||||
| -rw-r--r-- | test/ChangeLog | 7 | ||||
| -rw-r--r-- | test/automated/python-tests.el | 143 |
8 files changed, 385 insertions, 86 deletions
| @@ -1,3 +1,7 @@ | |||
| 1 | 2013-04-18 John Marino <gnugcc@marino.st> (tiny change) | ||
| 2 | |||
| 3 | * configure.ac: Add DragonFly BSD, mostly same as FreeBSD. (Bug#14068) | ||
| 4 | |||
| 1 | 2013-04-18 Glenn Morris <rgm@gnu.org> | 5 | 2013-04-18 Glenn Morris <rgm@gnu.org> |
| 2 | 6 | ||
| 3 | * configure.ac (AC_PROG_LN_S): Remove, too restrictive. | 7 | * configure.ac (AC_PROG_LN_S): Remove, too restrictive. |
diff --git a/configure.ac b/configure.ac index 79402a73ab2..d9b70d6ddd3 100644 --- a/configure.ac +++ b/configure.ac | |||
| @@ -439,6 +439,11 @@ case "${canonical}" in | |||
| 439 | opsys=freebsd | 439 | opsys=freebsd |
| 440 | ;; | 440 | ;; |
| 441 | 441 | ||
| 442 | ## DragonFly ports | ||
| 443 | *-*-dragonfly* ) | ||
| 444 | opsys=dragonfly | ||
| 445 | ;; | ||
| 446 | |||
| 442 | ## FreeBSD kernel + glibc based userland | 447 | ## FreeBSD kernel + glibc based userland |
| 443 | *-*-kfreebsd*gnu* ) | 448 | *-*-kfreebsd*gnu* ) |
| 444 | opsys=gnu-kfreebsd | 449 | opsys=gnu-kfreebsd |
| @@ -993,7 +998,7 @@ esac | |||
| 993 | 998 | ||
| 994 | LD_SWITCH_SYSTEM= | 999 | LD_SWITCH_SYSTEM= |
| 995 | case "$opsys" in | 1000 | case "$opsys" in |
| 996 | freebsd) | 1001 | freebsd|dragonfly) |
| 997 | ## Let `ld' find image libs and similar things in /usr/local/lib. | 1002 | ## Let `ld' find image libs and similar things in /usr/local/lib. |
| 998 | ## The system compiler, GCC, has apparently been modified to not | 1003 | ## The system compiler, GCC, has apparently been modified to not |
| 999 | ## look there, contrary to what a stock GCC would do. | 1004 | ## look there, contrary to what a stock GCC would do. |
| @@ -1080,7 +1085,7 @@ case "$opsys" in | |||
| 1080 | ## IBM's X11R5 uses -lIM and -liconv in AIX 3.2.2. | 1085 | ## IBM's X11R5 uses -lIM and -liconv in AIX 3.2.2. |
| 1081 | aix4-2) LIBS_SYSTEM="-lrts -lIM -liconv" ;; | 1086 | aix4-2) LIBS_SYSTEM="-lrts -lIM -liconv" ;; |
| 1082 | 1087 | ||
| 1083 | freebsd) LIBS_SYSTEM="-lutil" ;; | 1088 | freebsd|dragonfly) LIBS_SYSTEM="-lutil" ;; |
| 1084 | 1089 | ||
| 1085 | hpux*) LIBS_SYSTEM="-l:libdld.sl" ;; | 1090 | hpux*) LIBS_SYSTEM="-l:libdld.sl" ;; |
| 1086 | 1091 | ||
| @@ -1121,7 +1126,7 @@ case $opsys in | |||
| 1121 | ## Adding -lm confuses the dynamic linker, so omit it. | 1126 | ## Adding -lm confuses the dynamic linker, so omit it. |
| 1122 | LIB_MATH= | 1127 | LIB_MATH= |
| 1123 | ;; | 1128 | ;; |
| 1124 | freebsd ) | 1129 | freebsd | dragonfly ) |
| 1125 | SYSTEM_TYPE=berkeley-unix | 1130 | SYSTEM_TYPE=berkeley-unix |
| 1126 | ;; | 1131 | ;; |
| 1127 | gnu-linux | gnu-kfreebsd ) | 1132 | gnu-linux | gnu-kfreebsd ) |
| @@ -3062,7 +3067,7 @@ mail_lock=no | |||
| 3062 | case "$opsys" in | 3067 | case "$opsys" in |
| 3063 | aix4-2) mail_lock="lockf" ;; | 3068 | aix4-2) mail_lock="lockf" ;; |
| 3064 | 3069 | ||
| 3065 | gnu|freebsd|netbsd|openbsd|darwin|irix6-5) mail_lock="flock" ;; | 3070 | gnu|freebsd|dragonfly|netbsd|openbsd|darwin|irix6-5) mail_lock="flock" ;; |
| 3066 | 3071 | ||
| 3067 | ## On GNU/Linux systems, both methods are used by various mail programs. | 3072 | ## On GNU/Linux systems, both methods are used by various mail programs. |
| 3068 | ## I assume most people are using newer mailers that have heard of flock. | 3073 | ## I assume most people are using newer mailers that have heard of flock. |
| @@ -3248,7 +3253,7 @@ fail; | |||
| 3248 | fi | 3253 | fi |
| 3249 | ;; | 3254 | ;; |
| 3250 | 3255 | ||
| 3251 | openbsd) LIBS_TERMCAP="-lncurses" ;; | 3256 | openbsd | dragonfly) LIBS_TERMCAP="-lncurses" ;; |
| 3252 | 3257 | ||
| 3253 | ## hpux: Make sure we get select from libc rather than from libcurses | 3258 | ## hpux: Make sure we get select from libc rather than from libcurses |
| 3254 | ## because libcurses on HPUX 10.10 has a broken version of select. | 3259 | ## because libcurses on HPUX 10.10 has a broken version of select. |
| @@ -3695,7 +3700,7 @@ case $opsys in | |||
| 3695 | esac | 3700 | esac |
| 3696 | 3701 | ||
| 3697 | case $opsys in | 3702 | case $opsys in |
| 3698 | darwin | freebsd | netbsd | openbsd ) | 3703 | darwin | dragonfly | freebsd | netbsd | openbsd ) |
| 3699 | AC_DEFINE(DONT_REOPEN_PTY, 1, [Define if process.c does not need to | 3704 | AC_DEFINE(DONT_REOPEN_PTY, 1, [Define if process.c does not need to |
| 3700 | close a pty to make it a controlling terminal (it is already a | 3705 | close a pty to make it a controlling terminal (it is already a |
| 3701 | controlling terminal of the subprocess, because we did ioctl TIOCSCTTY).]) | 3706 | controlling terminal of the subprocess, because we did ioctl TIOCSCTTY).]) |
| @@ -3801,7 +3806,7 @@ case $opsys in | |||
| 3801 | AC_DEFINE(FIRST_PTY_LETTER, ['p']) | 3806 | AC_DEFINE(FIRST_PTY_LETTER, ['p']) |
| 3802 | ;; | 3807 | ;; |
| 3803 | 3808 | ||
| 3804 | gnu-linux | gnu-kfreebsd | freebsd | netbsd ) | 3809 | gnu-linux | gnu-kfreebsd | dragonfly | freebsd | netbsd ) |
| 3805 | dnl if HAVE_GRANTPT | 3810 | dnl if HAVE_GRANTPT |
| 3806 | if test "x$ac_cv_func_grantpt" = xyes; then | 3811 | if test "x$ac_cv_func_grantpt" = xyes; then |
| 3807 | AC_DEFINE(UNIX98_PTYS, 1, [Define if the system has Unix98 PTYs.]) | 3812 | AC_DEFINE(UNIX98_PTYS, 1, [Define if the system has Unix98 PTYs.]) |
| @@ -3884,7 +3889,7 @@ AH_TEMPLATE(SIGNALS_VIA_CHARACTERS, [Make process_send_signal work by | |||
| 3884 | case $opsys in | 3889 | case $opsys in |
| 3885 | dnl Perry Smith <pedz@ddivt1.austin.ibm.com> says this is correct for AIX. | 3890 | dnl Perry Smith <pedz@ddivt1.austin.ibm.com> says this is correct for AIX. |
| 3886 | dnl thomas@mathematik.uni-bremen.de says this is needed for IRIX. | 3891 | dnl thomas@mathematik.uni-bremen.de says this is needed for IRIX. |
| 3887 | aix4-2 | cygwin | gnu | irix6-5 | freebsd | netbsd | openbsd | darwin ) | 3892 | aix4-2 | cygwin | gnu | irix6-5 | dragonfly | freebsd | netbsd | openbsd | darwin ) |
| 3888 | AC_DEFINE(SIGNALS_VIA_CHARACTERS, 1) | 3893 | AC_DEFINE(SIGNALS_VIA_CHARACTERS, 1) |
| 3889 | ;; | 3894 | ;; |
| 3890 | 3895 | ||
| @@ -3933,7 +3938,7 @@ AH_TEMPLATE(TAB3, [Undocumented.]) | |||
| 3933 | case $opsys in | 3938 | case $opsys in |
| 3934 | darwin) AC_DEFINE(TAB3, OXTABS) ;; | 3939 | darwin) AC_DEFINE(TAB3, OXTABS) ;; |
| 3935 | 3940 | ||
| 3936 | gnu | freebsd | netbsd | openbsd ) | 3941 | gnu | dragonfly | freebsd | netbsd | openbsd ) |
| 3937 | AC_DEFINE(TABDLY, OXTABS, [Undocumented.]) | 3942 | AC_DEFINE(TABDLY, OXTABS, [Undocumented.]) |
| 3938 | AC_DEFINE(TAB3, OXTABS) | 3943 | AC_DEFINE(TAB3, OXTABS) |
| 3939 | ;; | 3944 | ;; |
| @@ -3987,7 +3992,7 @@ if test x$GCC = xyes; then | |||
| 3987 | else | 3992 | else |
| 3988 | case $opsys in | 3993 | case $opsys in |
| 3989 | dnl irix: Tested on Irix 6.5. SCM worked on earlier versions. | 3994 | dnl irix: Tested on Irix 6.5. SCM worked on earlier versions. |
| 3990 | freebsd | netbsd | openbsd | irix6-5 | sol2* ) | 3995 | dragonfly | freebsd | netbsd | openbsd | irix6-5 | sol2* ) |
| 3991 | AC_DEFINE(GC_SETJMP_WORKS, 1) | 3996 | AC_DEFINE(GC_SETJMP_WORKS, 1) |
| 3992 | ;; | 3997 | ;; |
| 3993 | esac | 3998 | esac |
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 98ba110ab33..a09d37352f7 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,30 @@ | |||
| 1 | 2013-04-19 Thierry Volpiatto <thierry.volpiatto@gmail.com> | ||
| 2 | |||
| 3 | * bookmark.el (bookmark-completing-read): Improve handling of empty | ||
| 4 | string (bug#14176). | ||
| 5 | |||
| 6 | 2013-04-19 Stefan Monnier <monnier@iro.umontreal.ca> | ||
| 7 | |||
| 8 | * vc/vc-dispatcher.el (vc-do-command): Get rid of default sentinel msg. | ||
| 9 | |||
| 10 | 2013-04-19 Fabián Ezequiel Gallina <fgallina@gnu.org> | ||
| 11 | |||
| 12 | New faster Imenu implementation (bug#14058). | ||
| 13 | * progmodes/python.el: | ||
| 14 | (python-imenu-prev-index-position): | ||
| 15 | (python-imenu-format-item-label-function) | ||
| 16 | (python-imenu-format-parent-item-label-function) | ||
| 17 | (python-imenu-format-parent-item-jump-label-function): | ||
| 18 | New vars. | ||
| 19 | (python-imenu-format-item-label) | ||
| 20 | (python-imenu-format-parent-item-label) | ||
| 21 | (python-imenu-format-parent-item-jump-label) | ||
| 22 | (python-imenu--put-parent, python-imenu--build-tree) | ||
| 23 | (python-imenu-create-index, python-imenu-create-flat-index) | ||
| 24 | (python-util-popn): New functions. | ||
| 25 | (python-mode): Set imenu-create-index-function to | ||
| 26 | python-imenu-create-index. | ||
| 27 | |||
| 1 | 2013-04-18 Stefan Monnier <monnier@iro.umontreal.ca> | 28 | 2013-04-18 Stefan Monnier <monnier@iro.umontreal.ca> |
| 2 | 29 | ||
| 3 | * winner.el (winner-active-region): Use region-active-p, activate-mark | 30 | * winner.el (winner-active-region): Use region-active-p, activate-mark |
diff --git a/lisp/bookmark.el b/lisp/bookmark.el index c1d8a4a0a5e..482cdf92752 100644 --- a/lisp/bookmark.el +++ b/lisp/bookmark.el | |||
| @@ -427,8 +427,8 @@ just return it." | |||
| 427 | "Prompting with PROMPT, read a bookmark name in completion. | 427 | "Prompting with PROMPT, read a bookmark name in completion. |
| 428 | PROMPT will get a \": \" stuck on the end no matter what, so you | 428 | PROMPT will get a \": \" stuck on the end no matter what, so you |
| 429 | probably don't want to include one yourself. | 429 | probably don't want to include one yourself. |
| 430 | Optional second arg DEFAULT is a string to return if the user enters | 430 | Optional arg DEFAULT is a string to return if the user input is empty. |
| 431 | the empty string." | 431 | If DEFAULT is nil then return empty string for empty input." |
| 432 | (bookmark-maybe-load-default-file) ; paranoia | 432 | (bookmark-maybe-load-default-file) ; paranoia |
| 433 | (if (listp last-nonmenu-event) | 433 | (if (listp last-nonmenu-event) |
| 434 | (bookmark-menu-popup-paned-menu t prompt | 434 | (bookmark-menu-popup-paned-menu t prompt |
| @@ -437,22 +437,17 @@ the empty string." | |||
| 437 | 'string-lessp) | 437 | 'string-lessp) |
| 438 | (bookmark-all-names))) | 438 | (bookmark-all-names))) |
| 439 | (let* ((completion-ignore-case bookmark-completion-ignore-case) | 439 | (let* ((completion-ignore-case bookmark-completion-ignore-case) |
| 440 | (default default) | 440 | (default (unless (equal "" default) default)) |
| 441 | (prompt (concat prompt (if default | 441 | (prompt (concat prompt (if default |
| 442 | (format " (%s): " default) | 442 | (format " (%s): " default) |
| 443 | ": "))) | 443 | ": ")))) |
| 444 | (str | 444 | (completing-read prompt |
| 445 | (completing-read prompt | 445 | (lambda (string pred action) |
| 446 | (lambda (string pred action) | 446 | (if (eq action 'metadata) |
| 447 | (if (eq action 'metadata) | 447 | '(metadata (category . bookmark)) |
| 448 | '(metadata (category . bookmark)) | 448 | (complete-with-action |
| 449 | (complete-with-action | 449 | action bookmark-alist string pred))) |
| 450 | action bookmark-alist string pred))) | 450 | nil 0 nil 'bookmark-history default)))) |
| 451 | nil | ||
| 452 | 0 | ||
| 453 | nil | ||
| 454 | 'bookmark-history))) | ||
| 455 | (if (string-equal "" str) default str)))) | ||
| 456 | 451 | ||
| 457 | 452 | ||
| 458 | (defmacro bookmark-maybe-historicize-string (string) | 453 | (defmacro bookmark-maybe-historicize-string (string) |
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index 53aff94ae0e..06d07d6ee3c 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el | |||
| @@ -177,12 +177,14 @@ | |||
| 177 | ;; might guessed you should run `python-shell-send-buffer' from time | 177 | ;; might guessed you should run `python-shell-send-buffer' from time |
| 178 | ;; to time to get better results too. | 178 | ;; to time to get better results too. |
| 179 | 179 | ||
| 180 | ;; Imenu: This mode supports Imenu in its most basic form, letting it | 180 | ;; Imenu: There are two index building functions to be used as |
| 181 | ;; build the necessary alist via `imenu-default-create-index-function' | 181 | ;; `imenu-create-index-function': `python-imenu-create-index' (the |
| 182 | ;; by having set `imenu-extract-index-name-function' to | 182 | ;; default one, builds the alist in form of a tree) and |
| 183 | ;; `python-info-current-defun' and | 183 | ;; `python-imenu-create-flat-index'. See also |
| 184 | ;; `imenu-prev-index-position-function' to | 184 | ;; `python-imenu-format-item-label-function', |
| 185 | ;; `python-imenu-prev-index-position'. | 185 | ;; `python-imenu-format-parent-item-label-function', |
| 186 | ;; `python-imenu-format-parent-item-jump-label-function' variables for | ||
| 187 | ;; changing the way labels are formatted in the tree version. | ||
| 186 | 188 | ||
| 187 | ;; If you used python-mode.el you probably will miss auto-indentation | 189 | ;; If you used python-mode.el you probably will miss auto-indentation |
| 188 | ;; when inserting newlines. To achieve the same behavior you have | 190 | ;; when inserting newlines. To achieve the same behavior you have |
| @@ -1194,7 +1196,7 @@ Returns nil if point is not in a def or class." | |||
| 1194 | 1196 | ||
| 1195 | (defun python-nav--syntactically (fn poscompfn &optional contextfn) | 1197 | (defun python-nav--syntactically (fn poscompfn &optional contextfn) |
| 1196 | "Move point using FN avoiding places with specific context. | 1198 | "Move point using FN avoiding places with specific context. |
| 1197 | FN must take no arguments. POSCOMPFN is a two arguments function | 1199 | FN must take no arguments. POSCOMPFN is a two arguments function |
| 1198 | used to compare current and previous point after it is moved | 1200 | used to compare current and previous point after it is moved |
| 1199 | using FN, this is normally a less-than or greater-than | 1201 | using FN, this is normally a less-than or greater-than |
| 1200 | comparison. Optional argument CONTEXTFN defaults to | 1202 | comparison. Optional argument CONTEXTFN defaults to |
| @@ -3008,15 +3010,192 @@ Interactively, prompt for symbol." | |||
| 3008 | 3010 | ||
| 3009 | ;;; Imenu | 3011 | ;;; Imenu |
| 3010 | 3012 | ||
| 3011 | (defun python-imenu-prev-index-position () | 3013 | (defvar python-imenu-format-item-label-function |
| 3012 | "Python mode's `imenu-prev-index-position-function'." | 3014 | 'python-imenu-format-item-label |
| 3013 | (let ((found)) | 3015 | "Imenu function used to format an item label. |
| 3014 | (while (and (setq found | 3016 | It must be a function with two arguments: TYPE and NAME.") |
| 3015 | (re-search-backward python-nav-beginning-of-defun-regexp nil t)) | 3017 | |
| 3016 | (not (python-info-looking-at-beginning-of-defun)))) | 3018 | (defvar python-imenu-format-parent-item-label-function |
| 3017 | (and found | 3019 | 'python-imenu-format-parent-item-label |
| 3018 | (python-info-looking-at-beginning-of-defun) | 3020 | "Imenu function used to format a parent item label. |
| 3019 | (python-info-current-defun)))) | 3021 | It must be a function with two arguments: TYPE and NAME.") |
| 3022 | |||
| 3023 | (defvar python-imenu-format-parent-item-jump-label-function | ||
| 3024 | 'python-imenu-format-parent-item-jump-label | ||
| 3025 | "Imenu function used to format a parent jump item label. | ||
| 3026 | It must be a function with two arguments: TYPE and NAME.") | ||
| 3027 | |||
| 3028 | (defun python-imenu-format-item-label (type name) | ||
| 3029 | "Return imenu label for single node using TYPE and NAME." | ||
| 3030 | (format "%s (%s)" name type)) | ||
| 3031 | |||
| 3032 | (defun python-imenu-format-parent-item-label (type name) | ||
| 3033 | "Return imenu label for parent node using TYPE and NAME." | ||
| 3034 | (format "%s..." (python-imenu-format-item-label type name))) | ||
| 3035 | |||
| 3036 | (defun python-imenu-format-parent-item-jump-label (type name) | ||
| 3037 | "Return imenu label for parent node jump using TYPE and NAME." | ||
| 3038 | (if (string= type "class") | ||
| 3039 | "*class definition*" | ||
| 3040 | "*function definition*")) | ||
| 3041 | |||
| 3042 | (defun python-imenu--put-parent (type name pos num-children tree &optional root) | ||
| 3043 | "Add the parent with TYPE, NAME, POS and NUM-CHILDREN to TREE. | ||
| 3044 | Optional Argument ROOT must be non-nil when the node being | ||
| 3045 | processed is the root of the TREE." | ||
| 3046 | (let ((label | ||
| 3047 | (funcall python-imenu-format-item-label-function type name)) | ||
| 3048 | (jump-label | ||
| 3049 | (funcall python-imenu-format-parent-item-jump-label-function type name))) | ||
| 3050 | (if root | ||
| 3051 | ;; This is the root, everything is a children. | ||
| 3052 | (cons label (cons (cons jump-label pos) tree)) | ||
| 3053 | ;; This is node a which may contain some children. | ||
| 3054 | (cons | ||
| 3055 | (cons label (cons (cons jump-label pos) | ||
| 3056 | ;; Append all the children | ||
| 3057 | (python-util-popn tree num-children))) | ||
| 3058 | ;; All previous non-children nodes. | ||
| 3059 | (nthcdr num-children tree))))) | ||
| 3060 | |||
| 3061 | (defun python-imenu--build-tree (&optional min-indent prev-indent num-children tree) | ||
| 3062 | "Recursively build the tree of nested definitions of a node. | ||
| 3063 | Arguments MIN-INDENT PREV-INDENT NUM-CHILDREN and TREE are | ||
| 3064 | internal and should not be passed explicitly unless you know what | ||
| 3065 | you are doing." | ||
| 3066 | (setq num-children (or num-children 0) | ||
| 3067 | min-indent (or min-indent 0)) | ||
| 3068 | (let* ((pos (python-nav-backward-defun)) | ||
| 3069 | (type) | ||
| 3070 | (name (when (and pos (looking-at python-nav-beginning-of-defun-regexp)) | ||
| 3071 | (let ((split (split-string (match-string-no-properties 0)))) | ||
| 3072 | (setq type (car split)) | ||
| 3073 | (cadr split)))) | ||
| 3074 | (label (when name | ||
| 3075 | (funcall python-imenu-format-item-label-function type name))) | ||
| 3076 | (indent (current-indentation))) | ||
| 3077 | (cond ((not pos) | ||
| 3078 | ;; No defun found, nothing to add. | ||
| 3079 | tree) | ||
| 3080 | ((equal indent 0) | ||
| 3081 | (if (> num-children 0) | ||
| 3082 | ;; Append it as the parent of everything collected to | ||
| 3083 | ;; this point. | ||
| 3084 | (python-imenu--put-parent type name pos num-children tree t) | ||
| 3085 | ;; There are no children, this is a lonely defun. | ||
| 3086 | (cons label pos))) | ||
| 3087 | ((equal min-indent indent) | ||
| 3088 | ;; Stop collecting nodes after moving to a position with | ||
| 3089 | ;; indentation equaling min-indent. This is specially | ||
| 3090 | ;; useful for navigating nested definitions recursively. | ||
| 3091 | tree) | ||
| 3092 | (t | ||
| 3093 | (python-imenu--build-tree | ||
| 3094 | min-indent | ||
| 3095 | indent | ||
| 3096 | ;; Add another children, either when this is the | ||
| 3097 | ;; first call or when indentation is | ||
| 3098 | ;; less-or-equal than previous. And do not | ||
| 3099 | ;; discard the number of children, because the | ||
| 3100 | ;; way code is scanned, all children are | ||
| 3101 | ;; collected until a root node yet to be found | ||
| 3102 | ;; appears. | ||
| 3103 | (if (or (not prev-indent) | ||
| 3104 | (and | ||
| 3105 | (> indent min-indent) | ||
| 3106 | (<= indent prev-indent))) | ||
| 3107 | (1+ num-children) | ||
| 3108 | num-children) | ||
| 3109 | (cond ((not prev-indent) | ||
| 3110 | ;; First call to the function: append this | ||
| 3111 | ;; defun to the index. | ||
| 3112 | (list (cons label pos))) | ||
| 3113 | ((= indent prev-indent) | ||
| 3114 | ;; Add another defun with the same depth | ||
| 3115 | ;; as the previous. | ||
| 3116 | (cons (cons label pos) tree)) | ||
| 3117 | ((and (< indent prev-indent) | ||
| 3118 | (< 0 num-children)) | ||
| 3119 | ;; There are children to be appended and | ||
| 3120 | ;; the previous defun had more | ||
| 3121 | ;; indentation, the current one must be a | ||
| 3122 | ;; parent. | ||
| 3123 | (python-imenu--put-parent type name pos num-children tree)) | ||
| 3124 | ((> indent prev-indent) | ||
| 3125 | ;; There are children defuns deeper than | ||
| 3126 | ;; current depth. Fear not, we already | ||
| 3127 | ;; know how to treat them. | ||
| 3128 | (cons | ||
| 3129 | (prog1 | ||
| 3130 | (python-imenu--build-tree | ||
| 3131 | prev-indent indent 1 (list (cons label pos))) | ||
| 3132 | ;; Adjustment: after scanning backwards | ||
| 3133 | ;; for all deeper children, we need to | ||
| 3134 | ;; continue our scan for a parent from | ||
| 3135 | ;; the current defun we are looking at. | ||
| 3136 | (python-nav-forward-defun)) | ||
| 3137 | tree)))))))) | ||
| 3138 | |||
| 3139 | (defun python-imenu-create-index () | ||
| 3140 | "Return tree Imenu alist for the current python buffer. | ||
| 3141 | Change `python-imenu-format-item-label-function', | ||
| 3142 | `python-imenu-format-parent-item-label-function', | ||
| 3143 | `python-imenu-format-parent-item-jump-label-function' to | ||
| 3144 | customize how labels are formatted." | ||
| 3145 | (goto-char (point-max)) | ||
| 3146 | (let ((index) | ||
| 3147 | (tree)) | ||
| 3148 | (while (setq tree (python-imenu--build-tree)) | ||
| 3149 | (setq index (cons tree index))) | ||
| 3150 | index)) | ||
| 3151 | |||
| 3152 | (defun python-imenu-create-flat-index (&optional alist prefix) | ||
| 3153 | "Return flat outline of the current python buffer for Imenu. | ||
| 3154 | Optional Argument ALIST is the tree to be flattened, when nil | ||
| 3155 | `python-imenu-build-index' is used with | ||
| 3156 | `python-imenu-format-parent-item-jump-label-function' | ||
| 3157 | `python-imenu-format-parent-item-label-function' | ||
| 3158 | `python-imenu-format-item-label-function' set to (lambda (type | ||
| 3159 | name) name). Optional Argument PREFIX is used in recursive calls | ||
| 3160 | and should not be passed explicitly. | ||
| 3161 | |||
| 3162 | Converts this: | ||
| 3163 | |||
| 3164 | \((\"Foo\" . 103) | ||
| 3165 | (\"Bar\" . 138) | ||
| 3166 | (\"decorator\" | ||
| 3167 | (\"decorator\" . 173) | ||
| 3168 | (\"wrap\" | ||
| 3169 | (\"wrap\" . 353) | ||
| 3170 | (\"wrapped_f\" . 393)))) | ||
| 3171 | |||
| 3172 | To this: | ||
| 3173 | |||
| 3174 | \((\"Foo\" . 103) | ||
| 3175 | (\"Bar\" . 138) | ||
| 3176 | (\"decorator\" . 173) | ||
| 3177 | (\"decorator.wrap\" . 353) | ||
| 3178 | (\"decorator.wrapped_f\" . 393))" | ||
| 3179 | (apply | ||
| 3180 | 'nconc | ||
| 3181 | (mapcar | ||
| 3182 | (lambda (item) | ||
| 3183 | (let ((name (if prefix | ||
| 3184 | (concat prefix "." (car item)) | ||
| 3185 | (car item))) | ||
| 3186 | (pos (cdr item))) | ||
| 3187 | (cond ((or (numberp pos) (markerp pos)) | ||
| 3188 | (list (cons name pos))) | ||
| 3189 | ((listp pos) | ||
| 3190 | (message "%S" item) | ||
| 3191 | (cons | ||
| 3192 | (cons name (cdar pos)) | ||
| 3193 | (python-imenu-create-flat-index (cddr item) name)))))) | ||
| 3194 | (or alist | ||
| 3195 | (let ((python-imenu-format-item-label-function (lambda (type name) name)) | ||
| 3196 | (python-imenu-format-parent-item-label-function (lambda (type name) name)) | ||
| 3197 | (python-imenu-format-parent-item-jump-label-function (lambda (type name) name))) | ||
| 3198 | (python-imenu-create-index)))))) | ||
| 3020 | 3199 | ||
| 3021 | 3200 | ||
| 3022 | ;;; Misc helpers | 3201 | ;;; Misc helpers |
| @@ -3337,6 +3516,22 @@ Optional argument DIRECTION defines the direction to move to." | |||
| 3337 | (goto-char comment-start)) | 3516 | (goto-char comment-start)) |
| 3338 | (forward-comment factor))) | 3517 | (forward-comment factor))) |
| 3339 | 3518 | ||
| 3519 | (defun python-util-popn (lst n) | ||
| 3520 | "Return LST first N elements. | ||
| 3521 | N should be an integer, when it's a natural negative number its | ||
| 3522 | opposite is used. When N is bigger than the length of LST, the | ||
| 3523 | list is returned as is." | ||
| 3524 | (let* ((n (min (abs n))) | ||
| 3525 | (len (length lst)) | ||
| 3526 | (acc)) | ||
| 3527 | (if (> n len) | ||
| 3528 | lst | ||
| 3529 | (while (< 0 n) | ||
| 3530 | (setq acc (cons (car lst) acc) | ||
| 3531 | lst (cdr lst) | ||
| 3532 | n (1- n))) | ||
| 3533 | (reverse acc)))) | ||
| 3534 | |||
| 3340 | 3535 | ||
| 3341 | ;;;###autoload | 3536 | ;;;###autoload |
| 3342 | (define-derived-mode python-mode prog-mode "Python" | 3537 | (define-derived-mode python-mode prog-mode "Python" |
| @@ -3382,11 +3577,8 @@ if that value is non-nil." | |||
| 3382 | (add-hook 'post-self-insert-hook | 3577 | (add-hook 'post-self-insert-hook |
| 3383 | 'python-indent-post-self-insert-function nil 'local) | 3578 | 'python-indent-post-self-insert-function nil 'local) |
| 3384 | 3579 | ||
| 3385 | (set (make-local-variable 'imenu-extract-index-name-function) | 3580 | (set (make-local-variable 'imenu-create-index-function) |
| 3386 | #'python-info-current-defun) | 3581 | #'python-imenu-create-index) |
| 3387 | |||
| 3388 | (set (make-local-variable 'imenu-prev-index-position-function) | ||
| 3389 | #'python-imenu-prev-index-position) | ||
| 3390 | 3582 | ||
| 3391 | (set (make-local-variable 'add-log-current-defun-function) | 3583 | (set (make-local-variable 'add-log-current-defun-function) |
| 3392 | #'python-info-current-defun) | 3584 | #'python-info-current-defun) |
diff --git a/lisp/vc/vc-dispatcher.el b/lisp/vc/vc-dispatcher.el index b03619e03d9..ed61adec1fe 100644 --- a/lisp/vc/vc-dispatcher.el +++ b/lisp/vc/vc-dispatcher.el | |||
| @@ -329,7 +329,9 @@ case, and the process object in the asynchronous case." | |||
| 329 | command squeezed)))) | 329 | command squeezed)))) |
| 330 | (when vc-command-messages | 330 | (when vc-command-messages |
| 331 | (message "Running %s in background..." full-command)) | 331 | (message "Running %s in background..." full-command)) |
| 332 | ;;(set-process-sentinel proc (lambda (p msg) (delete-process p))) | 332 | ;; Get rid of the default message insertion, in case we don't |
| 333 | ;; set a sentinel explicitly. | ||
| 334 | (set-process-sentinel proc #'ignore) | ||
| 333 | (set-process-filter proc 'vc-process-filter) | 335 | (set-process-filter proc 'vc-process-filter) |
| 334 | (setq status proc) | 336 | (setq status proc) |
| 335 | (when vc-command-messages | 337 | (when vc-command-messages |
diff --git a/test/ChangeLog b/test/ChangeLog index c8cb8ee3b54..0c240394c5c 100644 --- a/test/ChangeLog +++ b/test/ChangeLog | |||
| @@ -1,3 +1,10 @@ | |||
| 1 | 2013-04-19 Fabián Ezequiel Gallina <fgallina@gnu.org> | ||
| 2 | |||
| 3 | * automated/python-tests.el (python-imenu-prev-index-position-1): | ||
| 4 | Removed test. | ||
| 5 | (python-imenu-create-index-1, python-imenu-create-flat-index-1): | ||
| 6 | New tests. | ||
| 7 | |||
| 1 | 2013-04-17 Fabián Ezequiel Gallina <fgallina@gnu.org> | 8 | 2013-04-17 Fabián Ezequiel Gallina <fgallina@gnu.org> |
| 2 | 9 | ||
| 3 | * automated/python-tests.el (python-nav-backward-defun-2) | 10 | * automated/python-tests.el (python-nav-backward-defun-2) |
diff --git a/test/automated/python-tests.el b/test/automated/python-tests.el index 15089e6b393..8462a863b84 100644 --- a/test/automated/python-tests.el +++ b/test/automated/python-tests.el | |||
| @@ -1673,66 +1673,133 @@ Using `python-shell-interpreter' and | |||
| 1673 | 1673 | ||
| 1674 | 1674 | ||
| 1675 | ;;; Imenu | 1675 | ;;; Imenu |
| 1676 | (ert-deftest python-imenu-prev-index-position-1 () | 1676 | |
| 1677 | (require 'imenu) | 1677 | (ert-deftest python-imenu-create-index-1 () |
| 1678 | (python-tests-with-temp-buffer | 1678 | (python-tests-with-temp-buffer |
| 1679 | " | 1679 | " |
| 1680 | def decoratorFunctionWithArguments(arg1, arg2, arg3): | 1680 | class Foo(models.Model): |
| 1681 | pass | ||
| 1682 | |||
| 1683 | |||
| 1684 | class Bar(models.Model): | ||
| 1685 | pass | ||
| 1686 | |||
| 1687 | |||
| 1688 | def decorator(arg1, arg2, arg3): | ||
| 1681 | '''print decorated function call data to stdout. | 1689 | '''print decorated function call data to stdout. |
| 1682 | 1690 | ||
| 1683 | Usage: | 1691 | Usage: |
| 1684 | 1692 | ||
| 1685 | @decoratorFunctionWithArguments('arg1', 'arg2') | 1693 | @decorator('arg1', 'arg2') |
| 1686 | def func(a, b, c=True): | 1694 | def func(a, b, c=True): |
| 1687 | pass | 1695 | pass |
| 1688 | ''' | 1696 | ''' |
| 1689 | 1697 | ||
| 1690 | def wwrap(f): | 1698 | def wrap(f): |
| 1691 | print 'Inside wwrap()' | 1699 | print ('wrap') |
| 1692 | def wrapped_f(*args): | 1700 | def wrapped_f(*args): |
| 1693 | print 'Inside wrapped_f()' | 1701 | print ('wrapped_f') |
| 1694 | print 'Decorator arguments:', arg1, arg2, arg3 | 1702 | print ('Decorator arguments:', arg1, arg2, arg3) |
| 1695 | f(*args) | 1703 | f(*args) |
| 1696 | print 'After f(*args)' | 1704 | print ('called f(*args)') |
| 1697 | return wrapped_f | 1705 | return wrapped_f |
| 1698 | return wwrap | 1706 | return wrap |
| 1699 | 1707 | ||
| 1700 | def test(): # Some comment | ||
| 1701 | 'This is a test function' | ||
| 1702 | print 'test' | ||
| 1703 | 1708 | ||
| 1704 | class C(object): | 1709 | class Baz(object): |
| 1705 | 1710 | ||
| 1706 | def m(self): | 1711 | def a(self): |
| 1707 | self.c() | 1712 | pass |
| 1708 | 1713 | ||
| 1709 | def b(): | 1714 | def b(self): |
| 1710 | pass | 1715 | pass |
| 1711 | 1716 | ||
| 1712 | def a(): | 1717 | class Frob(object): |
| 1718 | |||
| 1719 | def c(self): | ||
| 1713 | pass | 1720 | pass |
| 1721 | " | ||
| 1722 | (goto-char (point-max)) | ||
| 1723 | (should (equal | ||
| 1724 | (list | ||
| 1725 | (cons "Foo (class)" (copy-marker 2)) | ||
| 1726 | (cons "Bar (class)" (copy-marker 38)) | ||
| 1727 | (list | ||
| 1728 | "decorator (def)" | ||
| 1729 | (cons "*function definition*" (copy-marker 74)) | ||
| 1730 | (list | ||
| 1731 | "wrap (def)" | ||
| 1732 | (cons "*function definition*" (copy-marker 254)) | ||
| 1733 | (cons "wrapped_f (def)" (copy-marker 294)))) | ||
| 1734 | (list | ||
| 1735 | "Baz (class)" | ||
| 1736 | (cons "*class definition*" (copy-marker 519)) | ||
| 1737 | (cons "a (def)" (copy-marker 539)) | ||
| 1738 | (cons "b (def)" (copy-marker 570)) | ||
| 1739 | (list | ||
| 1740 | "Frob (class)" | ||
| 1741 | (cons "*class definition*" (copy-marker 601)) | ||
| 1742 | (cons "c (def)" (copy-marker 626))))) | ||
| 1743 | (python-imenu-create-index))))) | ||
| 1744 | |||
| 1745 | (ert-deftest python-imenu-create-flat-index-1 () | ||
| 1746 | (python-tests-with-temp-buffer | ||
| 1747 | " | ||
| 1748 | class Foo(models.Model): | ||
| 1749 | pass | ||
| 1714 | 1750 | ||
| 1715 | def c(self): | 1751 | |
| 1752 | class Bar(models.Model): | ||
| 1753 | pass | ||
| 1754 | |||
| 1755 | |||
| 1756 | def decorator(arg1, arg2, arg3): | ||
| 1757 | '''print decorated function call data to stdout. | ||
| 1758 | |||
| 1759 | Usage: | ||
| 1760 | |||
| 1761 | @decorator('arg1', 'arg2') | ||
| 1762 | def func(a, b, c=True): | ||
| 1763 | pass | ||
| 1764 | ''' | ||
| 1765 | |||
| 1766 | def wrap(f): | ||
| 1767 | print ('wrap') | ||
| 1768 | def wrapped_f(*args): | ||
| 1769 | print ('wrapped_f') | ||
| 1770 | print ('Decorator arguments:', arg1, arg2, arg3) | ||
| 1771 | f(*args) | ||
| 1772 | print ('called f(*args)') | ||
| 1773 | return wrapped_f | ||
| 1774 | return wrap | ||
| 1775 | |||
| 1776 | |||
| 1777 | class Baz(object): | ||
| 1778 | |||
| 1779 | def a(self): | ||
| 1780 | pass | ||
| 1781 | |||
| 1782 | def b(self): | ||
| 1716 | pass | 1783 | pass |
| 1784 | |||
| 1785 | class Frob(object): | ||
| 1786 | |||
| 1787 | def c(self): | ||
| 1788 | pass | ||
| 1717 | " | 1789 | " |
| 1718 | (let ((expected | 1790 | (goto-char (point-max)) |
| 1719 | '(("*Rescan*" . -99) | 1791 | (should (equal |
| 1720 | ("decoratorFunctionWithArguments" . 2) | 1792 | (list (cons "Foo" (copy-marker 2)) |
| 1721 | ("decoratorFunctionWithArguments.wwrap" . 224) | 1793 | (cons "Bar" (copy-marker 38)) |
| 1722 | ("decoratorFunctionWithArguments.wwrap.wrapped_f" . 273) | 1794 | (cons "decorator" (copy-marker 74)) |
| 1723 | ("test" . 500) | 1795 | (cons "decorator.wrap" (copy-marker 254)) |
| 1724 | ("C" . 575) | 1796 | (cons "decorator.wrap.wrapped_f" (copy-marker 294)) |
| 1725 | ("C.m" . 593) | 1797 | (cons "Baz" (copy-marker 519)) |
| 1726 | ("C.m.b" . 628) | 1798 | (cons "Baz.a" (copy-marker 539)) |
| 1727 | ("C.m.a" . 663) | 1799 | (cons "Baz.b" (copy-marker 570)) |
| 1728 | ("C.c" . 698)))) | 1800 | (cons "Baz.Frob" (copy-marker 601)) |
| 1729 | (mapc | 1801 | (cons "Baz.Frob.c" (copy-marker 626))) |
| 1730 | (lambda (elt) | 1802 | (python-imenu-create-flat-index))))) |
| 1731 | (should (= (cdr (assoc-string (car elt) expected)) | ||
| 1732 | (if (markerp (cdr elt)) | ||
| 1733 | (marker-position (cdr elt)) | ||
| 1734 | (cdr elt))))) | ||
| 1735 | (imenu--make-index-alist))))) | ||
| 1736 | 1803 | ||
| 1737 | 1804 | ||
| 1738 | ;;; Misc helpers | 1805 | ;;; Misc helpers |