aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoakim Verona2013-04-19 08:30:26 +0200
committerJoakim Verona2013-04-19 08:30:26 +0200
commit4fe629bae8dac446053cacc1f10e4279df56d891 (patch)
tree391fe40bf643483568764513d704dbce4d53874c
parent2c9934db35546fb83c060318de178b63f33d42fd (diff)
parent7d6883367a54b4eee342aa861ef73e4191151ef0 (diff)
downloademacs-4fe629bae8dac446053cacc1f10e4279df56d891.tar.gz
emacs-4fe629bae8dac446053cacc1f10e4279df56d891.zip
auto upstream
-rw-r--r--ChangeLog4
-rw-r--r--autogen/Makefile.in2
-rwxr-xr-xautogen/configure34
-rw-r--r--configure.ac25
-rw-r--r--lisp/ChangeLog38
-rw-r--r--lisp/bookmark.el27
-rw-r--r--lisp/net/tramp-sh.el2
-rw-r--r--lisp/progmodes/python.el234
-rw-r--r--lisp/simple.el2
-rw-r--r--lisp/vc/vc-dispatcher.el4
-rw-r--r--lisp/winner.el6
-rw-r--r--test/ChangeLog7
-rw-r--r--test/automated/python-tests.el143
13 files changed, 427 insertions, 101 deletions
diff --git a/ChangeLog b/ChangeLog
index 573a8021eeb..dc6c0bfc3ec 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
12013-04-18 John Marino <gnugcc@marino.st> (tiny change)
2
3 * configure.ac: Add DragonFly BSD, mostly same as FreeBSD. (Bug#14068)
4
12013-04-18 Glenn Morris <rgm@gnu.org> 52013-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/autogen/Makefile.in b/autogen/Makefile.in
index 5f213903e9b..912aefe095a 100644
--- a/autogen/Makefile.in
+++ b/autogen/Makefile.in
@@ -663,7 +663,7 @@ LIB_MATH = @LIB_MATH@
663LIB_PTHREAD = @LIB_PTHREAD@ 663LIB_PTHREAD = @LIB_PTHREAD@
664LIB_PTHREAD_SIGMASK = @LIB_PTHREAD_SIGMASK@ 664LIB_PTHREAD_SIGMASK = @LIB_PTHREAD_SIGMASK@
665LIB_TIMER_TIME = @LIB_TIMER_TIME@ 665LIB_TIMER_TIME = @LIB_TIMER_TIME@
666LN_S = @LN_S@ 666LN_S_FILEONLY = @LN_S_FILEONLY@
667LTLIBINTL = @LTLIBINTL@ 667LTLIBINTL = @LTLIBINTL@
668LTLIBOBJS = @LTLIBOBJS@ 668LTLIBOBJS = @LTLIBOBJS@
669M17N_FLT_CFLAGS = @M17N_FLT_CFLAGS@ 669M17N_FLT_CFLAGS = @M17N_FLT_CFLAGS@
diff --git a/autogen/configure b/autogen/configure
index cc0e18b7d8f..8e69c9ceffc 100755
--- a/autogen/configure
+++ b/autogen/configure
@@ -1363,7 +1363,7 @@ HAVE_MAKEINFO
1363PAXCTL 1363PAXCTL
1364GZIP_PROG 1364GZIP_PROG
1365INSTALL_INFO 1365INSTALL_INFO
1366LN_S 1366LN_S_FILEONLY
1367GNULIB_WARN_CFLAGS 1367GNULIB_WARN_CFLAGS
1368WARN_CFLAGS 1368WARN_CFLAGS
1369WERROR_CFLAGS 1369WERROR_CFLAGS
@@ -8115,18 +8115,36 @@ fi
8115 8115
8116 8116
8117 8117
8118{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ln -s works" >&5 8118
8119$as_echo_n "checking whether ln -s works... " >&6; } 8119
8120LN_S=$as_ln_s 8120
8121if test "$LN_S" = "ln -s"; then 8121{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ln -s works for files in the same directory" >&5
8122 { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 8122$as_echo_n "checking whether ln -s works for files in the same directory... " >&6; }
8123rm -f conf$$ conf$$.file
8124
8125LN_S_FILEONLY='cp -p'
8126
8127if (echo >conf$$.file) 2>/dev/null; then
8128 if ln -s conf$$.file conf$$ 2>/dev/null; then
8129 LN_S_FILEONLY='ln -s'
8130 elif ln conf$$.file conf$$ 2>/dev/null; then
8131 LN_S_FILEONLY=ln
8132 fi
8133fi
8134
8135rm -f conf$$ conf$$.file
8136
8137if test "$LN_S_FILEONLY" = "ln -s"; then
8138 { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
8123$as_echo "yes" >&6; } 8139$as_echo "yes" >&6; }
8124else 8140else
8125 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no, using $LN_S" >&5 8141 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no, using $LN_S_FILEONLY" >&5
8126$as_echo "no, using $LN_S" >&6; } 8142$as_echo "no, using $LN_S_FILEONLY" >&6; }
8127fi 8143fi
8128 8144
8129 8145
8146
8147
8130# Extract the first word of "install-info", so it can be a program name with args. 8148# Extract the first word of "install-info", so it can be a program name with args.
8131set dummy install-info; ac_word=$2 8149set dummy install-info; ac_word=$2
8132{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 8150{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
diff --git a/configure.ac b/configure.ac
index d6109cedce3..b5ac2db9099 100644
--- a/configure.ac
+++ b/configure.ac
@@ -441,6 +441,11 @@ case "${canonical}" in
441 opsys=freebsd 441 opsys=freebsd
442 ;; 442 ;;
443 443
444 ## DragonFly ports
445 *-*-dragonfly* )
446 opsys=dragonfly
447 ;;
448
444 ## FreeBSD kernel + glibc based userland 449 ## FreeBSD kernel + glibc based userland
445 *-*-kfreebsd*gnu* ) 450 *-*-kfreebsd*gnu* )
446 opsys=gnu-kfreebsd 451 opsys=gnu-kfreebsd
@@ -970,7 +975,7 @@ esac
970 975
971LD_SWITCH_SYSTEM= 976LD_SWITCH_SYSTEM=
972case "$opsys" in 977case "$opsys" in
973 freebsd) 978 freebsd|dragonfly)
974 ## Let `ld' find image libs and similar things in /usr/local/lib. 979 ## Let `ld' find image libs and similar things in /usr/local/lib.
975 ## The system compiler, GCC, has apparently been modified to not 980 ## The system compiler, GCC, has apparently been modified to not
976 ## look there, contrary to what a stock GCC would do. 981 ## look there, contrary to what a stock GCC would do.
@@ -1056,7 +1061,7 @@ case "$opsys" in
1056 ## IBM's X11R5 uses -lIM and -liconv in AIX 3.2.2. 1061 ## IBM's X11R5 uses -lIM and -liconv in AIX 3.2.2.
1057 aix4-2) LIBS_SYSTEM="-lrts -lIM -liconv" ;; 1062 aix4-2) LIBS_SYSTEM="-lrts -lIM -liconv" ;;
1058 1063
1059 freebsd) LIBS_SYSTEM="-lutil" ;; 1064 freebsd|dragonfly) LIBS_SYSTEM="-lutil" ;;
1060 1065
1061 hpux*) LIBS_SYSTEM="-l:libdld.sl" ;; 1066 hpux*) LIBS_SYSTEM="-l:libdld.sl" ;;
1062 1067
@@ -1097,7 +1102,7 @@ case $opsys in
1097 ## Adding -lm confuses the dynamic linker, so omit it. 1102 ## Adding -lm confuses the dynamic linker, so omit it.
1098 LIB_MATH= 1103 LIB_MATH=
1099 ;; 1104 ;;
1100 freebsd ) 1105 freebsd | dragonfly )
1101 SYSTEM_TYPE=berkeley-unix 1106 SYSTEM_TYPE=berkeley-unix
1102 ;; 1107 ;;
1103 gnu-linux | gnu-kfreebsd ) 1108 gnu-linux | gnu-kfreebsd )
@@ -2927,7 +2932,7 @@ mail_lock=no
2927case "$opsys" in 2932case "$opsys" in
2928 aix4-2) mail_lock="lockf" ;; 2933 aix4-2) mail_lock="lockf" ;;
2929 2934
2930 gnu|freebsd|netbsd|openbsd|darwin|irix6-5) mail_lock="flock" ;; 2935 gnu|freebsd|dragonfly|netbsd|openbsd|darwin|irix6-5) mail_lock="flock" ;;
2931 2936
2932 ## On GNU/Linux systems, both methods are used by various mail programs. 2937 ## On GNU/Linux systems, both methods are used by various mail programs.
2933 ## I assume most people are using newer mailers that have heard of flock. 2938 ## I assume most people are using newer mailers that have heard of flock.
@@ -3099,7 +3104,7 @@ fail;
3099 fi 3104 fi
3100 ;; 3105 ;;
3101 3106
3102 openbsd) LIBS_TERMCAP="-lncurses" ;; 3107 openbsd | dragonfly) LIBS_TERMCAP="-lncurses" ;;
3103 3108
3104 ## hpux: Make sure we get select from libc rather than from libcurses 3109 ## hpux: Make sure we get select from libc rather than from libcurses
3105 ## because libcurses on HPUX 10.10 has a broken version of select. 3110 ## because libcurses on HPUX 10.10 has a broken version of select.
@@ -3522,7 +3527,7 @@ case $opsys in
3522esac 3527esac
3523 3528
3524case $opsys in 3529case $opsys in
3525 darwin | freebsd | netbsd | openbsd ) 3530 darwin | dragonfly | freebsd | netbsd | openbsd )
3526 AC_DEFINE(DONT_REOPEN_PTY, 1, [Define if process.c does not need to 3531 AC_DEFINE(DONT_REOPEN_PTY, 1, [Define if process.c does not need to
3527 close a pty to make it a controlling terminal (it is already a 3532 close a pty to make it a controlling terminal (it is already a
3528 controlling terminal of the subprocess, because we did ioctl TIOCSCTTY).]) 3533 controlling terminal of the subprocess, because we did ioctl TIOCSCTTY).])
@@ -3628,7 +3633,7 @@ case $opsys in
3628 AC_DEFINE(FIRST_PTY_LETTER, ['p']) 3633 AC_DEFINE(FIRST_PTY_LETTER, ['p'])
3629 ;; 3634 ;;
3630 3635
3631 gnu-linux | gnu-kfreebsd | freebsd | netbsd ) 3636 gnu-linux | gnu-kfreebsd | dragonfly | freebsd | netbsd )
3632 dnl if HAVE_GRANTPT 3637 dnl if HAVE_GRANTPT
3633 if test "x$ac_cv_func_grantpt" = xyes; then 3638 if test "x$ac_cv_func_grantpt" = xyes; then
3634 AC_DEFINE(UNIX98_PTYS, 1, [Define if the system has Unix98 PTYs.]) 3639 AC_DEFINE(UNIX98_PTYS, 1, [Define if the system has Unix98 PTYs.])
@@ -3711,7 +3716,7 @@ AH_TEMPLATE(SIGNALS_VIA_CHARACTERS, [Make process_send_signal work by
3711case $opsys in 3716case $opsys in
3712 dnl Perry Smith <pedz@ddivt1.austin.ibm.com> says this is correct for AIX. 3717 dnl Perry Smith <pedz@ddivt1.austin.ibm.com> says this is correct for AIX.
3713 dnl thomas@mathematik.uni-bremen.de says this is needed for IRIX. 3718 dnl thomas@mathematik.uni-bremen.de says this is needed for IRIX.
3714 aix4-2 | cygwin | gnu | irix6-5 | freebsd | netbsd | openbsd | darwin ) 3719 aix4-2 | cygwin | gnu | irix6-5 | dragonfly | freebsd | netbsd | openbsd | darwin )
3715 AC_DEFINE(SIGNALS_VIA_CHARACTERS, 1) 3720 AC_DEFINE(SIGNALS_VIA_CHARACTERS, 1)
3716 ;; 3721 ;;
3717 3722
@@ -3760,7 +3765,7 @@ AH_TEMPLATE(TAB3, [Undocumented.])
3760case $opsys in 3765case $opsys in
3761 darwin) AC_DEFINE(TAB3, OXTABS) ;; 3766 darwin) AC_DEFINE(TAB3, OXTABS) ;;
3762 3767
3763 gnu | freebsd | netbsd | openbsd ) 3768 gnu | dragonfly | freebsd | netbsd | openbsd )
3764 AC_DEFINE(TABDLY, OXTABS, [Undocumented.]) 3769 AC_DEFINE(TABDLY, OXTABS, [Undocumented.])
3765 AC_DEFINE(TAB3, OXTABS) 3770 AC_DEFINE(TAB3, OXTABS)
3766 ;; 3771 ;;
@@ -3814,7 +3819,7 @@ if test x$GCC = xyes; then
3814else 3819else
3815 case $opsys in 3820 case $opsys in
3816 dnl irix: Tested on Irix 6.5. SCM worked on earlier versions. 3821 dnl irix: Tested on Irix 6.5. SCM worked on earlier versions.
3817 freebsd | netbsd | openbsd | irix6-5 | sol2* ) 3822 dragonfly | freebsd | netbsd | openbsd | irix6-5 | sol2* )
3818 AC_DEFINE(GC_SETJMP_WORKS, 1) 3823 AC_DEFINE(GC_SETJMP_WORKS, 1)
3819 ;; 3824 ;;
3820 esac 3825 esac
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 516833ccaa2..a09d37352f7 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,41 @@
12013-04-19 Thierry Volpiatto <thierry.volpiatto@gmail.com>
2
3 * bookmark.el (bookmark-completing-read): Improve handling of empty
4 string (bug#14176).
5
62013-04-19 Stefan Monnier <monnier@iro.umontreal.ca>
7
8 * vc/vc-dispatcher.el (vc-do-command): Get rid of default sentinel msg.
9
102013-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
282013-04-18 Stefan Monnier <monnier@iro.umontreal.ca>
29
30 * winner.el (winner-active-region): Use region-active-p, activate-mark
31 and deactivate-mark (bug#14225).
32
33 * simple.el (deactivate-mark): Don't inline it.
34
352013-04-18 Michael Albinus <michael.albinus@gmx.de>
36
37 * net/tramp-sh.el (tramp-remote-process-environment): Add "TMOUT=0".
38
12013-04-18 Tassilo Horn <tsdh@gnu.org> 392013-04-18 Tassilo Horn <tsdh@gnu.org>
2 40
3 * files.el (auto-mode-alist): Delete OpenDocument and StarOffice 41 * files.el (auto-mode-alist): Delete OpenDocument and StarOffice
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.
428PROMPT will get a \": \" stuck on the end no matter what, so you 428PROMPT will get a \": \" stuck on the end no matter what, so you
429probably don't want to include one yourself. 429probably don't want to include one yourself.
430Optional second arg DEFAULT is a string to return if the user enters 430Optional arg DEFAULT is a string to return if the user input is empty.
431the empty string." 431If 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/net/tramp-sh.el b/lisp/net/tramp-sh.el
index da2dcc71c5c..f28df1ce160 100644
--- a/lisp/net/tramp-sh.el
+++ b/lisp/net/tramp-sh.el
@@ -422,7 +422,7 @@ as given in your `~/.profile'."
422 422
423;;;###tramp-autoload 423;;;###tramp-autoload
424(defcustom tramp-remote-process-environment 424(defcustom tramp-remote-process-environment
425 `("HISTFILE=$HOME/.tramp_history" "HISTSIZE=1" "LC_ALL=C" 425 `("HISTFILE=$HOME/.tramp_history" "HISTSIZE=1" "TMOUT=0" "LC_ALL=C"
426 ,(format "TERM=%s" tramp-terminal-type) 426 ,(format "TERM=%s" tramp-terminal-type)
427 "EMACS=t" ;; Deprecated. 427 "EMACS=t" ;; Deprecated.
428 ,(format "INSIDE_EMACS='%s,tramp:%s'" emacs-version tramp-version) 428 ,(format "INSIDE_EMACS='%s,tramp:%s'" emacs-version tramp-version)
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.
1197FN must take no arguments. POSCOMPFN is a two arguments function 1199FN must take no arguments. POSCOMPFN is a two arguments function
1198used to compare current and previous point after it is moved 1200used to compare current and previous point after it is moved
1199using FN, this is normally a less-than or greater-than 1201using FN, this is normally a less-than or greater-than
1200comparison. Optional argument CONTEXTFN defaults to 1202comparison. 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 3016It 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)))) 3021It 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.
3026It 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.
3044Optional Argument ROOT must be non-nil when the node being
3045processed 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.
3063Arguments MIN-INDENT PREV-INDENT NUM-CHILDREN and TREE are
3064internal and should not be passed explicitly unless you know what
3065you 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.
3141Change `python-imenu-format-item-label-function',
3142`python-imenu-format-parent-item-label-function',
3143`python-imenu-format-parent-item-jump-label-function' to
3144customize 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.
3154Optional 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
3159name) name). Optional Argument PREFIX is used in recursive calls
3160and should not be passed explicitly.
3161
3162Converts this:
3163
3164 \((\"Foo\" . 103)
3165 (\"Bar\" . 138)
3166 (\"decorator\"
3167 (\"decorator\" . 173)
3168 (\"wrap\"
3169 (\"wrap\" . 353)
3170 (\"wrapped_f\" . 393))))
3171
3172To 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.
3521N should be an integer, when it's a natural negative number its
3522opposite is used. When N is bigger than the length of LST, the
3523list 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/simple.el b/lisp/simple.el
index 3f28b8413e0..5fda9021004 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -4177,7 +4177,7 @@ a mistake; see the documentation of `set-mark'."
4177 (marker-position (mark-marker)) 4177 (marker-position (mark-marker))
4178 (signal 'mark-inactive nil))) 4178 (signal 'mark-inactive nil)))
4179 4179
4180(defsubst deactivate-mark (&optional force) 4180(defun deactivate-mark (&optional force)
4181 "Deactivate the mark. 4181 "Deactivate the mark.
4182If Transient Mark mode is disabled, this function normally does 4182If Transient Mark mode is disabled, this function normally does
4183nothing; but if FORCE is non-nil, it deactivates the mark anyway. 4183nothing; but if FORCE is non-nil, it deactivates the mark anyway.
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/lisp/winner.el b/lisp/winner.el
index dfbd15b6676..f521ba0521b 100644
--- a/lisp/winner.el
+++ b/lisp/winner.el
@@ -45,10 +45,8 @@
45 (if (featurep 'xemacs) 45 (if (featurep 'xemacs)
46 `(if ,store (zmacs-activate-region) 46 `(if ,store (zmacs-activate-region)
47 (zmacs-deactivate-region)) 47 (zmacs-deactivate-region))
48 `(setq mark-active ,store))))) 48 `(if ,store (activate-mark) (deactivate-mark))))))
49 (if (boundp 'mark-active) 49 (region-active-p))
50 mark-active
51 (region-active-p)))
52 50
53(defalias 'winner-edges 51(defalias 'winner-edges
54 (if (featurep 'xemacs) 'window-pixel-edges 'window-edges)) 52 (if (featurep 'xemacs) 'window-pixel-edges 'window-edges))
diff --git a/test/ChangeLog b/test/ChangeLog
index c8cb8ee3b54..0c240394c5c 100644
--- a/test/ChangeLog
+++ b/test/ChangeLog
@@ -1,3 +1,10 @@
12013-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
12013-04-17 Fabián Ezequiel Gallina <fgallina@gnu.org> 82013-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 "
1680def decoratorFunctionWithArguments(arg1, arg2, arg3): 1680class Foo(models.Model):
1681 pass
1682
1683
1684class Bar(models.Model):
1685 pass
1686
1687
1688def 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
1700def test(): # Some comment
1701 'This is a test function'
1702 print 'test'
1703 1708
1704class C(object): 1709class 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 "
1748class Foo(models.Model):
1749 pass
1714 1750
1715 def c(self): 1751
1752class Bar(models.Model):
1753 pass
1754
1755
1756def 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
1777class 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