Skip to content
Browse files

Reorganized all the stuff II

  • Loading branch information...
1 parent a8e9e26 commit 13b1af716c7e180cd8fd253ecc31db8fb3cd73a8 @gabrielelanaro committed Oct 20, 2010
Showing with 11,715 additions and 0 deletions.
  1. +66 −0 doc/Usage.rst
  2. +480 −0 extensions/auto-complete/auto-complete-config.el
  3. +1,897 −0 extensions/auto-complete/auto-complete.el
  4. +255 −0 extensions/auto-complete/fuzzy.el
  5. +1,061 −0 extensions/auto-complete/popup.el
  6. +57 −0 extensions/cython-mode.el
  7. +16 −0 extensions/emacs-dbgr/.gitignore
  8. +1 −0 extensions/emacs-dbgr/AUTHORS
  9. +1,019 −0 extensions/emacs-dbgr/ChangeLog
  10. +250 −0 extensions/emacs-dbgr/INSTALL
  11. +22 −0 extensions/emacs-dbgr/Makefile.am
  12. 0 extensions/emacs-dbgr/NEWS
  13. +19 −0 extensions/emacs-dbgr/README.textile
  14. +7 −0 extensions/emacs-dbgr/autogen.sh
  15. +43 −0 extensions/emacs-dbgr/configure.ac
  16. +68 −0 extensions/emacs-dbgr/dbgr.el
  17. +5 −0 extensions/emacs-dbgr/dbgr/.gitignore
  18. +10 −0 extensions/emacs-dbgr/dbgr/Makefile.am
  19. +5 −0 extensions/emacs-dbgr/dbgr/common/.gitignore
  20. +16 −0 extensions/emacs-dbgr/dbgr/common/Makefile.am
  21. +169 −0 extensions/emacs-dbgr/dbgr/common/bp.el
  22. +94 −0 extensions/emacs-dbgr/dbgr/common/buffer.el
  23. +169 −0 extensions/emacs-dbgr/dbgr/common/cmdbuf.el
  24. +91 −0 extensions/emacs-dbgr/dbgr/common/cmds.el
  25. +201 −0 extensions/emacs-dbgr/dbgr/common/core.el
  26. +8 −0 extensions/emacs-dbgr/dbgr/common/custom.el
  27. +45 −0 extensions/emacs-dbgr/dbgr/common/file.el
  28. +133 −0 extensions/emacs-dbgr/dbgr/common/fringe.el
  29. +67 −0 extensions/emacs-dbgr/dbgr/common/helper.el
  30. +13 −0 extensions/emacs-dbgr/dbgr/common/init.el
  31. +5 −0 extensions/emacs-dbgr/dbgr/common/init/.gitignore
  32. +9 −0 extensions/emacs-dbgr/dbgr/common/init/Makefile.am
  33. +41 −0 extensions/emacs-dbgr/dbgr/common/init/bashdb.el
  34. +39 −0 extensions/emacs-dbgr/dbgr/common/init/gdb.el
  35. +46 −0 extensions/emacs-dbgr/dbgr/common/init/kshdb.el
  36. +46 −0 extensions/emacs-dbgr/dbgr/common/init/pydb.el
  37. +66 −0 extensions/emacs-dbgr/dbgr/common/init/pydbgr.el
  38. +64 −0 extensions/emacs-dbgr/dbgr/common/init/rbdbgr.el
  39. +54 −0 extensions/emacs-dbgr/dbgr/common/init/rdebug.el
  40. +30 −0 extensions/emacs-dbgr/dbgr/common/init/remake.el
  41. +64 −0 extensions/emacs-dbgr/dbgr/common/init/trepan.el
  42. +64 −0 extensions/emacs-dbgr/dbgr/common/init/trepanx.el
  43. +38 −0 extensions/emacs-dbgr/dbgr/common/init/zshdb.el
  44. +101 −0 extensions/emacs-dbgr/dbgr/common/key.el
  45. +80 −0 extensions/emacs-dbgr/dbgr/common/loc.el
  46. +100 −0 extensions/emacs-dbgr/dbgr/common/lochist.el
  47. +135 −0 extensions/emacs-dbgr/dbgr/common/menu.el
  48. +30 −0 extensions/emacs-dbgr/dbgr/common/regexp.el
  49. +33 −0 extensions/emacs-dbgr/dbgr/common/reset.el
  50. +236 −0 extensions/emacs-dbgr/dbgr/common/send.el
  51. +84 −0 extensions/emacs-dbgr/dbgr/common/shortkey.el
  52. +145 −0 extensions/emacs-dbgr/dbgr/common/srcbuf.el
  53. +119 −0 extensions/emacs-dbgr/dbgr/common/track-mode.el
  54. +366 −0 extensions/emacs-dbgr/dbgr/common/track.el
  55. +115 −0 extensions/emacs-dbgr/dbgr/common/window.el
  56. +7 −0 extensions/emacs-dbgr/dbgr/gdb/.gitignore
  57. +6 −0 extensions/emacs-dbgr/dbgr/gdb/Makefile.am
  58. +149 −0 extensions/emacs-dbgr/dbgr/gdb/core.el
  59. +75 −0 extensions/emacs-dbgr/dbgr/gdb/gdb.el
  60. +29 −0 extensions/emacs-dbgr/dbgr/gdb/track-mode.el
  61. +6 −0 extensions/emacs-dbgr/dbgr/pydbgr/.gitignore
  62. +6 −0 extensions/emacs-dbgr/dbgr/pydbgr/Makefile.am
  63. +14 −0 extensions/emacs-dbgr/dbgr/pydbgr/cmds.el
  64. +220 −0 extensions/emacs-dbgr/dbgr/pydbgr/core.el
  65. +77 −0 extensions/emacs-dbgr/dbgr/pydbgr/pydbgr.el
  66. +30 −0 extensions/emacs-dbgr/dbgr/pydbgr/track-mode.el
  67. +6 −0 extensions/emacs-dbgr/dbgr/rbdbgr/.gitignore
  68. +4 −0 extensions/emacs-dbgr/dbgr/rbdbgr/Makefile.am
  69. +11 −0 extensions/emacs-dbgr/dbgr/rbdbgr/cmds.el
  70. +226 −0 extensions/emacs-dbgr/dbgr/rbdbgr/core.el
  71. +78 −0 extensions/emacs-dbgr/dbgr/rbdbgr/rbdbgr.el
  72. +59 −0 extensions/emacs-dbgr/dbgr/rbdbgr/track-mode.el
  73. +6 −0 extensions/emacs-dbgr/dbgr/rdebug/.gitignore
  74. +4 −0 extensions/emacs-dbgr/dbgr/rdebug/Makefile.am
  75. +17 −0 extensions/emacs-dbgr/dbgr/rdebug/cmds.el
  76. +220 −0 extensions/emacs-dbgr/dbgr/rdebug/core.el
  77. +131 −0 extensions/emacs-dbgr/dbgr/rdebug/rdebug.el
  78. +34 −0 extensions/emacs-dbgr/dbgr/rdebug/track-mode.el
  79. +5 −0 extensions/emacs-dbgr/dbgr/trepan/.gitignore
  80. +4 −0 extensions/emacs-dbgr/dbgr/trepan/Makefile.am
  81. +32 −0 extensions/emacs-dbgr/dbgr/trepan/cmds.el
  82. +230 −0 extensions/emacs-dbgr/dbgr/trepan/core.el
  83. +43 −0 extensions/emacs-dbgr/dbgr/trepan/track-mode.el
  84. +78 −0 extensions/emacs-dbgr/dbgr/trepan/trepan.el
  85. +5 −0 extensions/emacs-dbgr/dbgr/trepanx/.gitignore
  86. +4 −0 extensions/emacs-dbgr/dbgr/trepanx/Makefile.am
  87. +18 −0 extensions/emacs-dbgr/dbgr/trepanx/cmds.el
  88. +226 −0 extensions/emacs-dbgr/dbgr/trepanx/core.el
  89. +39 −0 extensions/emacs-dbgr/dbgr/trepanx/track-mode.el
  90. +78 −0 extensions/emacs-dbgr/dbgr/trepanx/trepanx.el
  91. +87 −0 extensions/emacs-dbgr/elisp-comp
  92. +145 −0 extensions/emacs-dbgr/load-relative.el
  93. +118 −0 extensions/emacs-dbgr/loc-changes.el
  94. +4 −0 extensions/emacs-dbgr/test/.gitignore
  95. +62 −0 extensions/emacs-dbgr/test/Makefile.am
  96. +42 −0 extensions/emacs-dbgr/test/gcd.py
  97. +19 −0 extensions/emacs-dbgr/test/gcd.rb
  98. +51 −0 extensions/emacs-dbgr/test/test-bp.el
  99. +42 −0 extensions/emacs-dbgr/test/test-cmdbuf.el
  100. +85 −0 extensions/emacs-dbgr/test/test-core.el
  101. +28 −0 extensions/emacs-dbgr/test/test-dbgr.el
  102. +36 −0 extensions/emacs-dbgr/test/test-file.el
  103. +61 −0 extensions/emacs-dbgr/test/test-helper.el
  104. +52 −0 extensions/emacs-dbgr/test/test-loc.el
  105. +66 −0 extensions/emacs-dbgr/test/test-lochist.el
  106. +50 −0 extensions/emacs-dbgr/test/test-pydbgr.el
  107. +50 −0 extensions/emacs-dbgr/test/test-rdebug.el
  108. +49 −0 extensions/emacs-dbgr/test/test-regexp-gdb.el
  109. +94 −0 extensions/emacs-dbgr/test/test-regexp-pydbgr.el
Sorry, we could not display the entire diff because too many files (682) changed.
View
66 doc/Usage.rst
@@ -0,0 +1,66 @@
+Typical Workflow
+================
+
+Intro
+-----
+
+Emacs-for-python pacakage is configured to be upstarted quickly, you shouln't spend your time in configuring and tweaking your emacs environment (and searching for appropriate extensions).
+
+Most of the selected extensions are "intelligent", they aren't intrusive and they don't touch your focus.
+
+After installing the package (it's a matter of load-file), fire up emacs.
+
+Starting
+--------
+
+To open a new file you can proceed as usual, with the `C-x C-f` keystrokes, you would see the ido-mode prompt with fuzzy completion enabled, it's fairly intuitive, type some keywords and you will be searching throught files. It remembers your choices and prompt you for the most used files.
+
+Editing
+-------
+
+After opening your python module you will have automatically activated some useful things:
+
+- flymake error checking, errors are displayed automatically with a red line, hover your mouse over the line to see an error message.
+
+- auto-completion it complete words in the current buffers, unfortunately I haven't found a good way to include "intellisense".
+
+
+There are also editing facilities:
+
+- *snippets* with yasnippet (with modified, more python-compliant snippets). Type the start of a word, like "class", press TAB and it expands itself in a snippet. It's integrated with auto-completion, they don't collide.
+
+- *autoclosing brackets*, type a bracket, it will be closed automatically. Select a region of text, type an opening bracket, the text is wrapped between brackets automatically. You can't live without that.
+
+- *open-next-line*: type `C-o` inside a sentence, you will be teleported to the next line, with the correct indentation.
+
+After editing the files you may want to execute the code. I would not recommend the execution facilities of "python-mode", instead I suggest you to act in this way::
+
+ M-x compile
+ <interactive> python whathever_test_to_do
+
+In this way the tracebacks are automatically highlighted and you can re-run easily the command (Be careful to the working directory!)
+
+Very Good! Test are all green, you may want to register your changes to version control::
+
+ C-x v v
+
+This will select the right thing to do, if the file is unregistered, it will be registered, else it will commit and prompt you for logging message. If you have other needs, I suggest you to spawn a shell and use it.
+
+Others
+------
+
+Need to do 2+2?::
+
+ M-c q
+
+Will prompt you for an expression, the result is in the kill ring, you can yank it in the text with `C-y`
+
+Cut/Copy/Paste from external applications is easy, the keys are remapped with the `super` key::
+
+ Cut: s-x
+ Copy: s-c
+ Paste: s-v
+
+The buffer are improved with the same ido interface plus Ibuffer, it's much colorful and has nice sorting functionalities.
+
+Can't go with `M-Tab` keys (the desktop keep switching application)? No problem it's remapped with `C-Tab`.
View
480 extensions/auto-complete/auto-complete-config.el
@@ -0,0 +1,480 @@
+;;; auto-complete-config.el --- auto-complete additional configuations
+
+;; Copyright (C) 2009, 2010 Tomohiro Matsuyama
+
+;; Author: Tomohiro Matsuyama <m2ym.pub@gmail.com>
+;; Keywords: convenience
+;; Version: 1.3
+
+;; 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 <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;;
+
+;;; Code:
+
+(eval-when-compile
+ (require 'cl))
+
+(require 'auto-complete)
+
+
+
+;;;; Additional sources
+
+;; imenu
+
+(defvar ac-imenu-index nil)
+
+(ac-clear-variable-every-10-minutes 'ac-imenu-index)
+
+(defun ac-imenu-candidates ()
+ (loop with i = 0
+ with stack = (progn
+ (unless (local-variable-p 'ac-imenu-index)
+ (make-local-variable 'ac-imenu-index))
+ (or ac-imenu-index
+ (setq ac-imenu-index
+ (ignore-errors
+ (with-no-warnings
+ (imenu--make-index-alist))))))
+ with result
+ while (and stack (or (not (integerp ac-limit))
+ (< i ac-limit)))
+ for node = (pop stack)
+ if (consp node)
+ do
+ (let ((car (car node))
+ (cdr (cdr node)))
+ (if (consp cdr)
+ (mapc (lambda (child)
+ (push child stack))
+ cdr)
+ (when (and (stringp car)
+ (string-match (concat "^" (regexp-quote ac-prefix)) car))
+ ;; Remove extra characters
+ (if (string-match "^.*\\(()\\|=\\|<>\\)$" car)
+ (setq car (substring car 0 (match-beginning 1))))
+ (push car result)
+ (incf i))))
+ finally return (nreverse result)))
+
+(ac-define-source imenu
+ '((depends imenu)
+ (candidates . ac-imenu-candidates)
+ (symbol . "s")))
+
+;; gtags
+
+(defface ac-gtags-candidate-face
+ '((t (:background "lightgray" :foreground "navy")))
+ "Face for gtags candidate"
+ :group 'auto-complete)
+
+(defface ac-gtags-selection-face
+ '((t (:background "navy" :foreground "white")))
+ "Face for the gtags selected candidate."
+ :group 'auto-complete)
+
+(defun ac-gtags-candidate ()
+ (ignore-errors
+ (split-string (shell-command-to-string (format "global -ci %s" ac-prefix)) "\n")))
+
+(ac-define-source gtags
+ '((candidates . ac-gtags-candidate)
+ (candidate-face . ac-gtags-candidate-face)
+ (selection-face . ac-gtags-selection-face)
+ (requires . 3)
+ (symbol . "s")))
+
+;; yasnippet
+
+(defface ac-yasnippet-candidate-face
+ '((t (:background "sandybrown" :foreground "black")))
+ "Face for yasnippet candidate."
+ :group 'auto-complete)
+
+(defface ac-yasnippet-selection-face
+ '((t (:background "coral3" :foreground "white")))
+ "Face for the yasnippet selected candidate."
+ :group 'auto-complete)
+
+(defun ac-yasnippet-table-hash (table)
+ (cond
+ ((fboundp 'yas/snippet-table-hash)
+ (yas/snippet-table-hash table))
+ ((fboundp 'yas/table-hash)
+ (yas/table-hash table))))
+
+(defun ac-yasnippet-table-parent (table)
+ (cond
+ ((fboundp 'yas/snippet-table-parent)
+ (yas/snippet-table-parent table))
+ ((fboundp 'yas/table-parent)
+ (yas/table-parent table))))
+
+(defun ac-yasnippet-candidate-1 (table)
+ (with-no-warnings
+ (let ((hashtab (ac-yasnippet-table-hash table))
+ (parent (ac-yasnippet-table-parent table))
+ candidates)
+ (maphash (lambda (key value)
+ (push key candidates))
+ hashtab)
+ (setq candidates (all-completions ac-prefix (nreverse candidates)))
+ (if parent
+ (setq candidates
+ (append candidates (ac-yasnippet-candidate-1 parent))))
+ candidates)))
+
+(defun ac-yasnippet-candidates ()
+ (with-no-warnings
+ (if (fboundp 'yas/get-snippet-tables)
+ ;; >0.6.0
+ (apply 'append (mapcar 'ac-yasnippet-candidate-1 (yas/get-snippet-tables major-mode)))
+ (let ((table
+ (if (fboundp 'yas/snippet-table)
+ ;; <0.6.0
+ (yas/snippet-table major-mode)
+ ;; 0.6.0
+ (yas/current-snippet-table))))
+ (if table
+ (ac-yasnippet-candidate-1 table))))))
+
+(ac-define-source yasnippet
+ '((depends yasnippet)
+ (candidates . ac-yasnippet-candidates)
+ (action . yas/expand)
+ (candidate-face . ac-yasnippet-candidate-face)
+ (selection-face . ac-yasnippet-selection-face)
+ (symbol . "a")))
+
+;; semantic
+
+(defun ac-semantic-candidates (prefix)
+ (with-no-warnings
+ (delete "" ; semantic sometimes returns an empty string
+ (mapcar 'semantic-tag-name
+ (ignore-errors
+ (or (semantic-analyze-possible-completions
+ (semantic-analyze-current-context))
+ (senator-find-tag-for-completion prefix)))))))
+
+(ac-define-source semantic
+ '((available . (or (require 'semantic-ia nil t)
+ (require 'semantic/ia nil t)))
+ (candidates . (ac-semantic-candidates ac-prefix))
+ (prefix . c-dot-ref)
+ (requires . 0)
+ (symbol . "m")))
+
+(ac-define-source semantic-raw
+ '((available . (or (require 'semantic-ia nil t)
+ (require 'semantic/ia nil t)))
+ (candidates . (ac-semantic-candidates ac-prefix))
+ (symbol . "s")))
+
+;; eclim
+
+(defun ac-eclim-candidates ()
+ (with-no-warnings
+ (loop for c in (eclim/java-complete)
+ collect (nth 1 c))))
+
+(ac-define-source eclim
+ '((candidates . ac-eclim-candidates)
+ (prefix . c-dot)
+ (requires . 0)
+ (symbol . "f")))
+
+;; css
+
+;; Copied from company-css.el
+(defconst ac-css-property-alist
+ ;; see http://www.w3.org/TR/CSS21/propidx.html
+ '(("azimuth" angle "left-side" "far-left" "left" "center-left" "center"
+ "center-right" "right" "far-right" "right-side" "behind" "leftwards"
+ "rightwards")
+ ("background" background-color background-image background-repeat
+ background-attachment background-position)
+ ("background-attachment" "scroll" "fixed")
+ ("background-color" color "transparent")
+ ("background-image" uri "none")
+ ("background-position" percentage length "left" "center" "right" percentage
+ length "top" "center" "bottom" "left" "center" "right" "top" "center"
+ "bottom")
+ ("background-repeat" "repeat" "repeat-x" "repeat-y" "no-repeat")
+ ("border" border-width border-style border-color)
+ ("border-bottom" border)
+ ("border-bottom-color" border-color)
+ ("border-bottom-style" border-style)
+ ("border-bottom-width" border-width)
+ ("border-collapse" "collapse" "separate")
+ ("border-color" color "transparent")
+ ("border-left" border)
+ ("border-left-color" border-color)
+ ("border-left-style" border-style)
+ ("border-left-width" border-width)
+ ("border-right" border)
+ ("border-right-color" border-color)
+ ("border-right-style" border-style)
+ ("border-right-width" border-width)
+ ("border-spacing" length length)
+ ("border-style" border-style)
+ ("border-top" border)
+ ("border-top-color" border-color)
+ ("border-top-style" border-style)
+ ("border-top-width" border-width)
+ ("border-width" border-width)
+ ("bottom" length percentage "auto")
+ ("caption-side" "top" "bottom")
+ ("clear" "none" "left" "right" "both")
+ ("clip" shape "auto")
+ ("color" color)
+ ("content" "normal" "none" string uri counter "attr()" "open-quote"
+ "close-quote" "no-open-quote" "no-close-quote")
+ ("counter-increment" identifier integer "none")
+ ("counter-reset" identifier integer "none")
+ ("cue" cue-before cue-after)
+ ("cue-after" uri "none")
+ ("cue-before" uri "none")
+ ("cursor" uri "*" "auto" "crosshair" "default" "pointer" "move" "e-resize"
+ "ne-resize" "nw-resize" "n-resize" "se-resize" "sw-resize" "s-resize"
+ "w-resize" "text" "wait" "help" "progress")
+ ("direction" "ltr" "rtl")
+ ("display" "inline" "block" "list-item" "run-in" "inline-block" "table"
+ "inline-table" "table-row-group" "table-header-group" "table-footer-group"
+ "table-row" "table-column-group" "table-column" "table-cell"
+ "table-caption" "none")
+ ("elevation" angle "below" "level" "above" "higher" "lower")
+ ("empty-cells" "show" "hide")
+ ("float" "left" "right" "none")
+ ("font" font-style font-variant font-weight font-size "/" line-height
+ font-family "caption" "icon" "menu" "message-box" "small-caption"
+ "status-bar")
+ ("font-family" family-name generic-family)
+ ("font-size" absolute-size relative-size length percentage)
+ ("font-style" "normal" "italic" "oblique")
+ ("font-variant" "normal" "small-caps")
+ ("font-weight" "normal" "bold" "bolder" "lighter" "100" "200" "300" "400"
+ "500" "600" "700" "800" "900")
+ ("height" length percentage "auto")
+ ("left" length percentage "auto")
+ ("letter-spacing" "normal" length)
+ ("line-height" "normal" number length percentage)
+ ("list-style" list-style-type list-style-position list-style-image)
+ ("list-style-image" uri "none")
+ ("list-style-position" "inside" "outside")
+ ("list-style-type" "disc" "circle" "square" "decimal" "decimal-leading-zero"
+ "lower-roman" "upper-roman" "lower-greek" "lower-latin" "upper-latin"
+ "armenian" "georgian" "lower-alpha" "upper-alpha" "none")
+ ("margin" margin-width)
+ ("margin-bottom" margin-width)
+ ("margin-left" margin-width)
+ ("margin-right" margin-width)
+ ("margin-top" margin-width)
+ ("max-height" length percentage "none")
+ ("max-width" length percentage "none")
+ ("min-height" length percentage)
+ ("min-width" length percentage)
+ ("orphans" integer)
+ ("outline" outline-color outline-style outline-width)
+ ("outline-color" color "invert")
+ ("outline-style" border-style)
+ ("outline-width" border-width)
+ ("overflow" "visible" "hidden" "scroll" "auto")
+ ("padding" padding-width)
+ ("padding-bottom" padding-width)
+ ("padding-left" padding-width)
+ ("padding-right" padding-width)
+ ("padding-top" padding-width)
+ ("page-break-after" "auto" "always" "avoid" "left" "right")
+ ("page-break-before" "auto" "always" "avoid" "left" "right")
+ ("page-break-inside" "avoid" "auto")
+ ("pause" time percentage)
+ ("pause-after" time percentage)
+ ("pause-before" time percentage)
+ ("pitch" frequency "x-low" "low" "medium" "high" "x-high")
+ ("pitch-range" number)
+ ("play-during" uri "mix" "repeat" "auto" "none")
+ ("position" "static" "relative" "absolute" "fixed")
+ ("quotes" string string "none")
+ ("richness" number)
+ ("right" length percentage "auto")
+ ("speak" "normal" "none" "spell-out")
+ ("speak-header" "once" "always")
+ ("speak-numeral" "digits" "continuous")
+ ("speak-punctuation" "code" "none")
+ ("speech-rate" number "x-slow" "slow" "medium" "fast" "x-fast" "faster"
+ "slower")
+ ("stress" number)
+ ("table-layout" "auto" "fixed")
+ ("text-align" "left" "right" "center" "justify")
+ ("text-decoration" "none" "underline" "overline" "line-through" "blink")
+ ("text-indent" length percentage)
+ ("text-transform" "capitalize" "uppercase" "lowercase" "none")
+ ("top" length percentage "auto")
+ ("unicode-bidi" "normal" "embed" "bidi-override")
+ ("vertical-align" "baseline" "sub" "super" "top" "text-top" "middle"
+ "bottom" "text-bottom" percentage length)
+ ("visibility" "visible" "hidden" "collapse")
+ ("voice-family" specific-voice generic-voice "*" specific-voice
+ generic-voice)
+ ("volume" number percentage "silent" "x-soft" "soft" "medium" "loud"
+ "x-loud")
+ ("white-space" "normal" "pre" "nowrap" "pre-wrap" "pre-line")
+ ("widows" integer)
+ ("width" length percentage "auto")
+ ("word-spacing" "normal" length)
+ ("z-index" "auto" integer))
+ "A list of CSS properties and their possible values.")
+
+(defconst ac-css-value-classes
+ '((absolute-size "xx-small" "x-small" "small" "medium" "large" "x-large"
+ "xx-large")
+ (border-style "none" "hidden" "dotted" "dashed" "solid" "double" "groove"
+ "ridge" "inset" "outset")
+ (color "aqua" "black" "blue" "fuchsia" "gray" "green" "lime" "maroon" "navy"
+ "olive" "orange" "purple" "red" "silver" "teal" "white" "yellow"
+ "rgb")
+ (counter "counter")
+ (family-name "Courier" "Helvetica" "Times")
+ (generic-family "serif" "sans-serif" "cursive" "fantasy" "monospace")
+ (generic-voice "male" "female" "child")
+ (margin-width "auto") ;; length percentage
+ (relative-size "larger" "smaller")
+ (shape "rect")
+ (uri "url"))
+ "A list of CSS property value classes and their contents.")
+
+(defconst ac-css-pseudo-classes
+ '("active" "after" "before" "first" "first-child" "first-letter" "first-line"
+ "focus" "hover" "lang" "left" "link" "right" "visited")
+ "Identifiers for CSS pseudo-elements and pseudo-classes.")
+
+(defvar ac-css-property nil
+ "Current editing property.")
+
+(defun ac-css-prefix ()
+ (when (save-excursion (re-search-backward "\\_<\\(.+?\\)\\_>\\s *:.*\\=" nil t))
+ (setq ac-css-property (match-string 1))
+ (or (ac-prefix-symbol) (point))))
+
+(defun ac-css-property-candidates ()
+ (or (loop with list = (assoc-default ac-css-property ac-css-property-alist)
+ with value
+ while (setq value (pop list))
+ if (symbolp value)
+ do (setq list
+ (append list
+ (or (assoc-default value ac-css-value-classes)
+ (assoc-default (symbol-name value) ac-css-property-alist))))
+ else collect value)
+ ac-css-pseudo-classes))
+
+(defvar ac-source-css-property
+ '((candidates . ac-css-property-candidates)
+ (prefix . ac-css-prefix)
+ (requires . 0)))
+
+
+
+;;;; Not maintained sources
+
+;; ropemacs
+
+(defvar ac-ropemacs-loaded nil)
+(defun ac-ropemacs-require ()
+ (with-no-warnings
+ (unless ac-ropemacs-loaded
+ (pymacs-load "ropemacs" "rope-")
+ (if (boundp 'ropemacs-enable-autoimport)
+ (setq ropemacs-enable-autoimport t))
+ (setq ac-ropemacs-loaded t))))
+
+(defun ac-ropemacs-setup ()
+ (ac-ropemacs-require)
+ ;(setq ac-sources (append (list 'ac-source-ropemacs) ac-sources))
+ (setq ac-omni-completion-sources '(("\\." ac-source-ropemacs))))
+
+(defun ac-ropemacs-initialize ()
+ (autoload 'pymacs-apply "pymacs")
+ (autoload 'pymacs-call "pymacs")
+ (autoload 'pymacs-eval "pymacs" nil t)
+ (autoload 'pymacs-exec "pymacs" nil t)
+ (autoload 'pymacs-load "pymacs" nil t)
+ (add-hook 'python-mode-hook 'ac-ropemacs-setup)
+ t)
+
+(defvar ac-ropemacs-completions-cache nil)
+(defvar ac-source-ropemacs
+ '((init
+ . (lambda ()
+ (setq ac-ropemacs-completions-cache
+ (mapcar
+ (lambda (completion)
+ (concat ac-prefix completion))
+ (ignore-errors
+ (rope-completions))))))
+ (candidates . ac-ropemacs-completions-cache)))
+
+;; rcodetools
+
+(defvar ac-source-rcodetools
+ '((init . (lambda ()
+ (require 'rcodetools)
+ (condition-case x
+ (save-excursion
+ (rct-exec-and-eval rct-complete-command-name "--completion-emacs-icicles"))
+ (error) (setq rct-method-completion-table nil))))
+ (candidates . (lambda ()
+ (all-completions
+ ac-prefix
+ (mapcar
+ (lambda (completion)
+ (replace-regexp-in-string "\t.*$" "" (car completion)))
+ rct-method-completion-table))))))
+
+
+
+;;;; Default settings
+
+(defun ac-common-setup ()
+ (add-to-list 'ac-sources 'ac-source-filename))
+
+(defun ac-emacs-lisp-mode-setup ()
+ (setq ac-sources (append '(ac-source-features ac-source-functions ac-source-yasnippet ac-source-variables ac-source-symbols) ac-sources)))
+
+(defun ac-cc-mode-setup ()
+ (setq ac-sources (append '(ac-source-yasnippet ac-source-gtags) ac-sources)))
+
+(defun ac-ruby-mode-setup ()
+ (make-local-variable 'ac-ignores)
+ (add-to-list 'ac-ignores "end"))
+
+(defun ac-css-mode-setup ()
+ (setq ac-sources (append '(ac-source-css-property) ac-sources)))
+
+(defun ac-config-default ()
+ (setq-default ac-sources '(ac-source-abbrev ac-source-dictionary ac-source-words-in-same-mode-buffers))
+ (add-hook 'emacs-lisp-mode-hook 'ac-emacs-lisp-mode-setup)
+ (add-hook 'c-mode-common-hook 'ac-cc-mode-setup)
+ (add-hook 'ruby-mode-hook 'ac-ruby-mode-setup)
+ (add-hook 'css-mode-hook 'ac-css-mode-setup)
+ (add-hook 'auto-complete-mode-hook 'ac-common-setup)
+ (global-auto-complete-mode t))
+
+(provide 'auto-complete-config)
+;;; auto-complete-config.el ends here
View
1,897 extensions/auto-complete/auto-complete.el
1,897 additions, 0 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
View
255 extensions/auto-complete/fuzzy.el
@@ -0,0 +1,255 @@
+;;; fuzzy.el --- Fuzzy matching utilities
+
+;; Copyright (C) 2010 Tomohiro Matsuyama
+
+;; Author: Tomohiro Matsuyama <m2ym.pub@gmail.com>
+;; Keywords: convenience
+
+;; 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 <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;;
+
+;;; Code:
+
+(eval-when-compile
+ (require 'cl))
+(require 'regexp-opt)
+
+(defgroup fuzzy nil
+ "Fuzzy matching utilities."
+ :group 'convenience
+ :prefix "fuzzy-")
+
+(defcustom fuzzy-accept-error-rate 0.10
+ "Error threshold."
+ :group 'fuzzy)
+
+(defvar fuzzy-accept-length-difference 2)
+
+(defvar fuzzy-regexp-some-char (format "\\w\\{0,%s\\}" fuzzy-accept-length-difference))
+
+
+
+;;; Functions
+
+(defun fuzzy-reverse-string (string)
+ (apply 'string (nreverse (append string nil))))
+
+(defun fuzzy-regexp-compile (string)
+ (labels ((oddp (n) (eq (logand n 1) 1))
+ (evenp (n) (eq (logand n 1) 0))
+ (opt (n) (regexp-opt-charset (append (substring string
+ (max 0 (- n 1))
+ (min (length string) (+ n 2))) nil))))
+ (concat
+ "\\("
+ (loop for i below (length string)
+ for c = (if (evenp i) (opt i) fuzzy-regexp-some-char)
+ concat c)
+ "\\|"
+ (loop for i below (length string)
+ for c = (if (oddp i) (opt i) fuzzy-regexp-some-char)
+ concat c)
+ "\\)")))
+
+(defalias 'fuzzy-edit-distance 'fuzzy-jaro-winkler-distance)
+
+(defun fuzzy-jaro-winkler-distance (s1 s2)
+ "http://en.wikipedia.org/wiki/Jaro-Winkler_distance"
+ (let* ((l1 (length s1))
+ (l2 (length s2))
+ (r (max 1 (1- (/ (max l1 l2) 2))))
+ (m 0)
+ (tr 0)
+ (p 0)
+ cs1 cs2)
+ (loop with seen = (make-vector l2 nil)
+ for i below l1
+ for c1 = (aref s1 i) do
+ (loop for j from (max 0 (- i r)) below (min l2 (+ i r))
+ for c2 = (aref s2 j)
+ if (and (char-equal c1 c2)
+ (null (aref seen j))) do
+ (push c1 cs1)
+ (aset seen j c2)
+ (incf m)
+ and return nil)
+ finally
+ (setq cs1 (nreverse cs1)
+ cs2 (loop for i below l2
+ for c = (aref seen i)
+ if c collect c)))
+ (loop for c1 in cs1
+ for c2 in cs2
+ if (not (char-equal c1 c2)) do
+ (incf tr))
+ (loop for i below (min m 5)
+ for c1 across s1
+ for c2 across s2
+ while (char-equal c1 c2) do
+ (incf p))
+ (if (eq m 0)
+ 0.0
+ (setq m (float m))
+ (let* ((dj (/ (+ (/ m l1) (/ m l2) (/ (- m (/ tr 2)) m)) 3))
+ (dw (+ dj (* p 0.1 (- 1 dj)))))
+ dw))))
+
+;; this function should be compiled
+(byte-compile 'fuzzy-jaro-winkler-distance)
+
+(defun fuzzy-match (s1 s2 &optional function)
+ (or function (setq function 'fuzzy-edit-distance))
+ (and (<= (abs (- (length s1) (length s2)))
+ fuzzy-accept-length-difference)
+ (>= (funcall function s1 s2)
+ (- 1 fuzzy-accept-error-rate))))
+
+(defun fuzzy-all-completions (string collection)
+ "all-completions family with fuzzy matching."
+ (loop with length = (length string)
+ for str in collection
+ for s = (substring str 0 (min (length str)
+ (+ length fuzzy-accept-length-difference)))
+ if (fuzzy-match string s)
+ collect str))
+
+
+
+;;; Search and Incremental Search
+
+(defvar fuzzy-search-cache nil)
+(defvar fuzzy-search-cache-string nil)
+
+(defun fuzzy-search-cache-activate ()
+ (setq fuzzy-search-cache (make-hash-table))
+ (setq fuzzy-search-cache-string nil))
+
+(defun fuzzy-search-cache-deactive ()
+ (setq fuzzy-search-cache nil)
+ (setq fuzzy-search-cache-string nil))
+
+(defun fuzzy-search-edit-distance (s1 s2)
+ (or (and fuzzy-search-cache
+ (cond
+ ((null fuzzy-search-cache-string)
+ (setq fuzzy-search-cache-string s1)
+ nil)
+ ((not (equal fuzzy-search-cache-string s1))
+ (setq fuzzy-search-cache-string s1)
+ (clrhash fuzzy-search-cache)
+ nil)
+ (t))
+ (gethash s2 fuzzy-search-cache))
+ (let ((d (fuzzy-edit-distance s1 s2)))
+ (if fuzzy-search-cache
+ (puthash s2 d fuzzy-search-cache))
+ d)))
+
+(defun fuzzy-search-match (s1 s2)
+ (fuzzy-match s1 s2 'fuzzy-search-edit-distance))
+
+(defun fuzzy-search-forward (string &optional bound noerror count)
+ (let* ((regexp (fuzzy-regexp-compile string))
+ match-data)
+ (save-excursion
+ (while (and (null match-data)
+ (re-search-forward regexp bound t))
+ (if (fuzzy-search-match string (match-string 1))
+ (setq match-data (match-data))
+ (goto-char (1+ (match-beginning 1))))))
+ (when match-data
+ (store-match-data match-data)
+ (goto-char (match-end 1)))))
+
+(defun fuzzy-search-backward (string &optional bound noerror count)
+ (let* ((regexp (fuzzy-regexp-compile string))
+ match-data begin end)
+ (save-excursion
+ (while (and (null match-data)
+ (re-search-backward regexp bound t))
+ (setq begin (match-beginning 1)
+ end (match-end 1))
+ (store-match-data nil)
+ (goto-char (max (point-min) (- begin (* (length string) 2))))
+ (while (re-search-forward regexp end t)
+ (if (fuzzy-search-match string (match-string 1))
+ (setq match-data (match-data))
+ (goto-char (1+ (match-beginning 1)))))
+ (unless match-data
+ (goto-char begin)))
+ (if match-data
+ (progn
+ (store-match-data match-data)
+ (goto-char (match-beginning 1)))
+ (store-match-data nil)))))
+
+(defvar fuzzy-isearch nil)
+(defvar fuzzy-isearch-failed-count 0)
+(defvar fuzzy-isearch-enabled 'on-failed)
+(defvar fuzzy-isearch-original-search-fun nil)
+(defvar fuzzy-isearch-prefix "[FUZZY] ")
+
+(defun fuzzy-isearch-activate ()
+ (setq fuzzy-isearch t)
+ (setq fuzzy-isearch-failed-count 0)
+ (fuzzy-search-cache-activate))
+
+(defun fuzzy-isearch-deactivate ()
+ (setq fuzzy-isearch nil)
+ (setq fuzzy-isearch-failed-count 0)
+ (fuzzy-search-cache-deactive))
+
+(defun fuzzy-isearch ()
+ (cond (isearch-word
+ (if isearch-forward 'word-search-forward 'word-search-backward))
+ (isearch-regexp
+ (if isearch-forward 're-search-forward 're-search-backward))
+ ((or fuzzy-isearch
+ (eq fuzzy-isearch-enabled 'always)
+ (and (eq fuzzy-isearch-enabled 'on-failed)
+ (null isearch-success)
+ isearch-wrapped
+ (> (setq fuzzy-isearch-failed-count (1+ fuzzy-isearch-failed-count))
+ 1)))
+ (unless fuzzy-isearch
+ ;(goto-char isearch-opoint)
+ (fuzzy-isearch-activate))
+ (if isearch-forward 'fuzzy-search-forward 'fuzzy-search-backward))
+ (t
+ (if isearch-forward 'search-forward 'search-backward))))
+
+(defun fuzzy-isearch-end-hook ()
+ (fuzzy-isearch-deactivate))
+
+(defun turn-on-fuzzy-isearch ()
+ (interactive)
+ (setq fuzzy-isearch-original-search-fun isearch-search-fun-function)
+ (setq isearch-search-fun-function 'fuzzy-isearch)
+ (add-hook 'isearch-mode-end-hook 'fuzzy-isearch-end-hook))
+
+(defun turn-off-fuzzy-isearch ()
+ (interactive)
+ (setq isearch-search-fun-function fuzzy-isearch-original-search-fun)
+ (remove-hook 'isearch-mode-end-hook 'fuzzy-isearch-end-hook))
+
+(defadvice isearch-message-prefix (after fuzzy-isearch-message-prefix activate)
+ (if fuzzy-isearch
+ (setq ad-return-value (concat fuzzy-isearch-prefix ad-return-value))
+ ad-return-value))
+
+(provide 'fuzzy)
+;;; fuzzy.el ends here
View
1,061 extensions/auto-complete/popup.el
@@ -0,0 +1,1061 @@
+;;; popup.el --- Visual popup interface
+
+;; Copyright (C) 2009, 2010 Tomohiro Matsuyama
+
+;; Author: Tomohiro Matsuyama <tomo@cx4a.org>
+;; Keywords: lisp
+;; Version: 0.4
+
+;; 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 <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;;
+
+;;; Code:
+
+(eval-when-compile
+ (require 'cl))
+
+
+
+;; Utilities
+
+(defvar popup-use-optimized-column-computation t
+ "Use optimized column computation routine.
+If there is a problem, please set it to nil.")
+
+;; Borrowed from anything.el
+(defmacro popup-aif (test-form then-form &rest else-forms)
+ "Anaphoric if. Temporary variable `it' is the result of test-form."
+ (declare (indent 2))
+ `(let ((it ,test-form))
+ (if it ,then-form ,@else-forms)))
+
+(defun popup-x-to-string (x)
+ "Convert any object to string effeciently.
+This is faster than prin1-to-string in many cases."
+ (typecase x
+ (string x)
+ (symbol (symbol-name x))
+ (integer (number-to-string x))
+ (float (number-to-string x))
+ (t (format "%s" x))))
+
+(defun popup-substring-by-width (string width)
+ "Return cons of substring and remaining string by `WIDTH'."
+ ;; Expand tabs with 4 spaces
+ (setq string (replace-regexp-in-string "\t" " " string))
+ (loop with len = (length string)
+ with w = 0
+ for l from 0
+ for c in (append string nil)
+ while (<= (incf w (char-width c)) width)
+ finally return
+ (if (< l len)
+ (cons (substring string 0 l) (substring string l))
+ (list string))))
+
+(defun popup-fill-string (string &optional width max-width justify squeeze)
+ "Split STRING into fixed width strings and return a cons cell like
+\(WIDTH . ROWS). Here, the car WIDTH indicates the actual maxim width of ROWS.
+
+The argument WIDTH specifies the width of filling each paragraph. WIDTH nil
+means don't perform any justification and word wrap. Note that this function
+doesn't add any padding characters at the end of each row.
+
+MAX-WIDTH, if WIDTH is nil, specifies the maximum number of columns.
+
+The optional fourth argument JUSTIFY specifies which kind of justification
+to do: `full', `left', `right', `center', or `none' (equivalent to nil).
+A value of t means handle each paragraph as specified by its text properties.
+
+SQUEEZE nil means leave whitespaces other than line breaks untouched."
+ (if (eq width 0)
+ (error "Can't fill string with 0 width"))
+ (if width
+ (setq max-width width))
+ (with-temp-buffer
+ (let ((tab-width 4)
+ (fill-column width)
+ (left-margin 0)
+ (kinsoku-limit 1)
+ indent-tabs-mode
+ row rows)
+ (insert string)
+ (untabify (point-min) (point-max))
+ (if width
+ (fill-region (point-min) (point-max) justify (not squeeze)))
+ (goto-char (point-min))
+ (setq width 0)
+ (while (prog2
+ (let ((line (buffer-substring
+ (point) (progn (end-of-line) (point)))))
+ (if max-width
+ (while (progn
+ (setq row (truncate-string-to-width line max-width)
+ width (max width (string-width row)))
+ (push row rows)
+ (if (not (= (length row) (length line)))
+ (setq line (substring line (length row))))))
+ (setq width (max width (string-width line)))
+ (push line rows)))
+ (< (point) (point-max))
+ (beginning-of-line 2)))
+ (cons width (nreverse rows)))))
+
+(defmacro popup-save-buffer-state (&rest body)
+ (declare (indent 0))
+ `(save-excursion
+ (let ((buffer-undo-list t)
+ (buffer-read-only nil)
+ (modified (buffer-modified-p)))
+ (unwind-protect
+ (progn ,@body)
+ (set-buffer-modified-p modified)))))
+
+(defun popup-preferred-width (list)
+ "Return preferred width of popup to show `LIST' beautifully."
+ (loop with tab-width = 4
+ for item in list
+ for summary = (popup-item-summary item)
+ maximize (string-width (popup-x-to-string item)) into width
+ if (stringp summary)
+ maximize (+ (string-width summary) 2) into summary-width
+ finally return (* (ceiling (/ (+ (or width 0) (or summary-width 0)) 10.0)) 10)))
+
+;; window-full-width-p is not defined in Emacs 22.1
+(defun popup-window-full-width-p (&optional window)
+ (if (fboundp 'window-full-width-p)
+ (window-full-width-p window)
+ (= (window-width window) (frame-width (window-frame (or window (selected-window)))))))
+
+;; truncated-partial-width-window-p is not defined in Emacs 22
+(defun popup-truncated-partial-width-window-p (&optional window)
+ (unless window
+ (setq window (selected-window)))
+ (unless (popup-window-full-width-p window)
+ (let ((t-p-w-w (buffer-local-value 'truncate-partial-width-windows
+ (window-buffer window))))
+ (if (integerp t-p-w-w)
+ (< (window-width window) t-p-w-w)
+ t-p-w-w))))
+
+(defun popup-current-physical-column ()
+ (or (when (and popup-use-optimized-column-computation
+ (eq (window-hscroll) 0))
+ (let ((current-column (current-column)))
+ (if (or (popup-truncated-partial-width-window-p)
+ truncate-lines
+ (< current-column (window-width)))
+ current-column)))
+ (car (posn-col-row (posn-at-point)))))
+
+(defun popup-last-line-of-buffer-p ()
+ (save-excursion (end-of-line) (/= (forward-line) 0)))
+
+(defun popup-lookup-key-by-event (function event)
+ (or (funcall function (vector event))
+ (if (symbolp event)
+ (popup-aif (get event 'event-symbol-element-mask)
+ (funcall function (vector (logior (or (get (car it) 'ascii-character) 0)
+ (cadr it))))))))
+
+
+
+;; Popup common
+
+(defgroup popup nil
+ "Visual popup interface"
+ :group 'lisp
+ :prefix "popup-")
+
+(defface popup-face
+ '((t (:background "lightgray" :foreground "black")))
+ "Face for popup."
+ :group 'popup)
+
+(defface popup-scroll-bar-foreground-face
+ '((t (:background "black")))
+ "Foreground face for scroll-bar."
+ :group 'popup)
+
+(defface popup-scroll-bar-background-face
+ '((t (:background "gray")))
+ "Background face for scroll-bar."
+ :group 'popup)
+
+(defvar popup-instances nil
+ "Popup instances.")
+
+(defvar popup-scroll-bar-foreground-char
+ (propertize " " 'face 'popup-scroll-bar-foreground-face)
+ "Foreground character for scroll-bar.")
+
+(defvar popup-scroll-bar-background-char
+ (propertize " " 'face 'popup-scroll-bar-background-face)
+ "Background character for scroll-bar.")
+
+(defstruct popup
+ point row column width height min-height direction overlays
+ parent depth
+ face selection-face
+ margin-left margin-right margin-left-cancel scroll-bar symbol
+ cursor offset scroll-top current-height list newlines
+ pattern original-list)
+
+(defun popup-item-propertize (item &rest properties)
+ "Same to `propertize` but this avoids overriding existed value with `nil` property."
+ (let (props)
+ (while properties
+ (when (cadr properties)
+ (push (car properties) props)
+ (push (cadr properties) props))
+ (setq properties (cddr properties)))
+ (apply 'propertize
+ (popup-x-to-string item)
+ (nreverse props))))
+
+(defun popup-item-property (item property)
+ (if (stringp item)
+ (get-text-property 0 property item)))
+
+(defun* popup-make-item (name
+ &key
+ value
+ popup-face
+ selection-face
+ sublist
+ document
+ symbol
+ summary)
+ "Utility function to make popup item.
+See also `popup-item-propertize'."
+ (popup-item-propertize name
+ 'value value
+ 'popup-face popup-face
+ 'selection-face selection-face
+ 'document document
+ 'symbol symbol
+ 'summary summary
+ 'sublist sublist))
+
+(defsubst popup-item-value (item) (popup-item-property item 'value))
+(defsubst popup-item-value-or-self (item) (or (popup-item-value item) item))
+(defsubst popup-item-popup-face (item) (popup-item-property item 'popup-face))
+(defsubst popup-item-selection-face (item) (popup-item-property item 'selection-face))
+(defsubst popup-item-document (item) (popup-item-property item 'document))
+(defsubst popup-item-summary (item) (popup-item-property item 'summary))
+(defsubst popup-item-symbol (item) (popup-item-property item 'symbol))
+(defsubst popup-item-sublist (item) (popup-item-property item 'sublist))
+
+(defun popup-item-documentation (item)
+ (let ((doc (popup-item-document item)))
+ (if (functionp doc)
+ (setq doc (funcall doc (popup-item-value-or-self item))))
+ doc))
+
+(defun popup-item-show-help-1 (item)
+ (let ((doc (popup-item-documentation item)))
+ (when doc
+ (with-current-buffer (get-buffer-create " *Popup Help*")
+ (erase-buffer)
+ (insert doc)
+ (goto-char (point-min))
+ (display-buffer (current-buffer)))
+ t)))
+
+(defun popup-item-show-help (item &optional persist)
+ (when item
+ (if (not persist)
+ (save-window-excursion
+ (when (popup-item-show-help-1 item)
+ (block nil
+ (while t
+ (clear-this-command-keys)
+ (let ((key (read-key-sequence-vector nil)))
+ (case (key-binding key)
+ ('scroll-other-window
+ (scroll-other-window))
+ ('scroll-other-window-down
+ (scroll-other-window-down nil))
+ (t
+ (setq unread-command-events (append key unread-command-events))
+ (return))))))))
+ (popup-item-show-help-1 item))))
+
+(defun popup-set-list (popup list)
+ (popup-set-filtered-list popup list)
+ (setf (popup-pattern popup) nil)
+ (setf (popup-original-list popup) list))
+
+(defun popup-set-filtered-list (popup list)
+ (setf (popup-list popup) list
+ (popup-offset popup) (if (> (popup-direction popup) 0)
+ 0
+ (max (- (popup-height popup) (length list)) 0))))
+
+(defun popup-selected-item (popup)
+ (nth (popup-cursor popup) (popup-list popup)))
+
+(defun popup-selected-line (popup)
+ (- (popup-cursor popup) (popup-scroll-top popup)))
+
+(defun popup-line-overlay (popup line)
+ (aref (popup-overlays popup) line))
+
+(defun popup-selected-line-overlay (popup)
+ (popup-line-overlay popup (popup-selected-line popup)))
+
+(defun popup-hide-line (popup line)
+ (let ((overlay (popup-line-overlay popup line)))
+ (overlay-put overlay 'display nil)
+ (overlay-put overlay 'after-string nil)))
+
+(defun popup-line-hidden-p (popup line)
+ (let ((overlay (popup-line-overlay popup line)))
+ (and (eq (overlay-get overlay 'display) nil)
+ (eq (overlay-get overlay 'after-string) nil))))
+
+(defun popup-set-line-item (popup line item face margin-left margin-right scroll-bar-char symbol summary)
+ (let* ((overlay (popup-line-overlay popup line))
+ (content (popup-create-line-string popup (popup-x-to-string item) margin-left margin-right symbol summary))
+ (start 0)
+ (prefix (overlay-get overlay 'prefix))
+ (postfix (overlay-get overlay 'postfix))
+ end)
+ ;; Overlap face properties
+ (if (get-text-property start 'face content)
+ (setq start (next-single-property-change start 'face content)))
+ (while (and start (setq end (next-single-property-change start 'face content)))
+ (put-text-property start end 'face face content)
+ (setq start (next-single-property-change end 'face content)))
+ (if start
+ (put-text-property start (length content) 'face face content))
+ (unless (overlay-get overlay 'dangle)
+ (overlay-put overlay 'display (concat prefix (substring content 0 1)))
+ (setq prefix nil
+ content (concat (substring content 1))))
+ (overlay-put overlay
+ 'after-string
+ (concat prefix
+ content
+ scroll-bar-char
+ postfix))))
+
+(defun popup-create-line-string (popup string margin-left margin-right symbol summary)
+ (let* ((popup-width (popup-width popup))
+ (summary-width (string-width summary))
+ (string (car (popup-substring-by-width string
+ (- popup-width
+ (if (> summary-width 0)
+ (+ summary-width 2)
+ 0)))))
+ (string-width (string-width string)))
+ (concat margin-left
+ string
+ (make-string (max (- popup-width string-width summary-width) 0) ? )
+ summary
+ symbol
+ margin-right)))
+
+(defun popup-live-p (popup)
+ (and popup (popup-overlays popup) t))
+
+(defun popup-child-point (popup &optional offset)
+ (overlay-end (popup-line-overlay popup
+ (or offset
+ (popup-selected-line popup)))))
+
+(defun* popup-create (point
+ width
+ height
+ &key
+ min-height
+ around
+ (face 'popup-face)
+ (selection-face face)
+ scroll-bar
+ margin-left
+ margin-right
+ symbol
+ parent
+ parent-offset)
+ (or margin-left (setq margin-left 0))
+ (or margin-right (setq margin-right 0))
+ (unless point
+ (setq point
+ (if parent (popup-child-point parent parent-offset) (point))))
+
+ (save-excursion
+ (goto-char point)
+ (let* ((row (line-number-at-pos))
+ (column (popup-current-physical-column))
+ (overlays (make-vector height nil))
+ (popup-width (+ width
+ (if scroll-bar 1 0)
+ margin-left
+ margin-right
+ (if symbol 2 0)))
+ margin-left-cancel
+ (window (selected-window))
+ (window-start (window-start))
+ (window-hscroll (window-hscroll))
+ (window-width (window-width))
+ (right (+ column popup-width))
+ (overflow (and (> right window-width)
+ (>= right popup-width)))
+ (foldable (and (null parent)
+ (>= column popup-width)))
+ (direction (or
+ ;; Currently the direction of cascade popup won't be changed
+ (and parent (popup-direction parent))
+
+ ;; Calculate direction
+ (if (and (> row height)
+ (> height (- (max 1 (- (window-height)
+ (if mode-line-format 1 0)
+ (if header-line-format 1 0)))
+ (count-lines window-start (point)))))
+ -1
+ 1)))
+ (depth (if parent (1+ (popup-depth parent)) 0))
+ (newlines (max 0 (+ (- height (count-lines point (point-max))) (if around 1 0))))
+ current-column)
+ (when (> newlines 0)
+ (popup-save-buffer-state
+ (goto-char (point-max))
+ (insert (make-string newlines ?\n))))
+
+ (if overflow
+ (if foldable
+ (progn
+ (decf column (- popup-width margin-left margin-right))
+ (unless around (move-to-column column)))
+ (when (not truncate-lines)
+ ;; Cut out overflow
+ (let ((d (1+ (- popup-width (- window-width column)))))
+ (decf popup-width d)
+ (decf width d)))
+ (decf column margin-left))
+ (decf column margin-left))
+ (when (and (null parent)
+ (< column 0))
+ ;; Cancel margin left
+ (setq column 0)
+ (decf popup-width margin-left)
+ (setq margin-left-cancel t))
+
+ (dotimes (i height)
+ (let (overlay begin w (dangle t) (prefix "") (postfix ""))
+ (when around
+ (if (>= emacs-major-version 23)
+ (vertical-motion (cons column direction))
+ (vertical-motion direction)
+ (move-to-column (+ (current-column) column))))
+ (setq around t
+ current-column (popup-current-physical-column))
+
+ (when (> current-column column)
+ (backward-char)
+ (setq current-column (popup-current-physical-column)))
+ (when (< current-column column)
+ ;; Extend short buffer lines by popup prefix (line of spaces)
+ (setq prefix (make-string (+ (if (= current-column 0)
+ (- window-hscroll (current-column))
+ 0)
+ (- column current-column))
+ ? )))
+
+ (setq begin (point))
+ (setq w (+ popup-width (length prefix)))
+ (while (and (not (eolp)) (> w 0))
+ (setq dangle nil)
+ (decf w (char-width (char-after)))
+ (forward-char))
+ (if (< w 0)
+ (setq postfix (make-string (- w) ? )))
+
+ (setq overlay (make-overlay begin (point)))
+ (overlay-put overlay 'window window)
+ (overlay-put overlay 'dangle dangle)
+ (overlay-put overlay 'prefix prefix)
+ (overlay-put overlay 'postfix postfix)
+ (overlay-put overlay 'width width)
+ (aset overlays
+ (if (> direction 0) i (- height i 1))
+ overlay)))
+ (loop for p from (- 10000 (* depth 1000))
+ for overlay in (nreverse (append overlays nil))
+ do (overlay-put overlay 'priority p))
+ (let ((it (make-popup :point point
+ :row row
+ :column column
+ :width width
+ :height height
+ :min-height min-height
+ :direction direction
+ :parent parent
+ :depth depth
+ :face face
+ :selection-face selection-face
+ :margin-left margin-left
+ :margin-right margin-right
+ :margin-left-cancel margin-left-cancel
+ :scroll-bar scroll-bar
+ :symbol symbol
+ :cursor 0
+ :scroll-top 0
+ :current-height 0
+ :list nil
+ :newlines newlines
+ :overlays overlays)))
+ (push it popup-instances)
+ it))))
+
+(defun popup-delete (popup)
+ (when (popup-live-p popup)
+ (popup-hide popup)
+ (mapc 'delete-overlay (popup-overlays popup))
+ (setf (popup-overlays popup) nil)
+ (setq popup-instances (delq popup popup-instances))
+ (let ((newlines (popup-newlines popup)))
+ (when (> newlines 0)
+ (popup-save-buffer-state
+ (goto-char (point-max))
+ (dotimes (i newlines)
+ (if (= (char-before) ?\n)
+ (delete-char -1)))))))
+ nil)
+
+(defun popup-draw (popup)
+ (loop with height = (popup-height popup)
+ with min-height = (popup-min-height popup)
+ with popup-face = (popup-face popup)
+ with selection-face = (popup-selection-face popup)
+ with list = (popup-list popup)
+ with length = (length list)
+ with thum-size = (max (/ (* height height) (max length 1)) 1)
+ with page-size = (/ (+ 0.0 (max length 1)) height)
+ with scroll-bar = (popup-scroll-bar popup)
+ with margin-left = (make-string (if (popup-margin-left-cancel popup) 0 (popup-margin-left popup)) ? )
+ with margin-right = (make-string (popup-margin-right popup) ? )
+ with symbol = (popup-symbol popup)
+ with cursor = (popup-cursor popup)
+ with scroll-top = (popup-scroll-top popup)
+ with offset = (popup-offset popup)
+ for o from offset
+ for i from scroll-top
+ while (< o height)
+ for item in (nthcdr scroll-top list)
+ for page-index = (* thum-size (/ o thum-size))
+ for face = (if (= i cursor)
+ (or (popup-item-selection-face item) selection-face)
+ (or (popup-item-popup-face item) popup-face))
+ for empty-char = (propertize " " 'face face)
+ for scroll-bar-char = (if scroll-bar
+ (cond
+ ((<= page-size 1)
+ empty-char)
+ ((and (> page-size 1)
+ (>= cursor (* page-index page-size))
+ (< cursor (* (+ page-index thum-size) page-size)))
+ popup-scroll-bar-foreground-char)
+ (t
+ popup-scroll-bar-background-char))
+ "")
+ for sym = (if symbol
+ (concat " " (or (popup-item-symbol item) " "))
+ "")
+ for summary = (or (popup-item-summary item) "")
+
+ do
+ ;; Show line and set item to the line
+ (popup-set-line-item popup o item face margin-left margin-right scroll-bar-char sym summary)
+
+ finally
+ ;; Remember current height
+ (setf (popup-current-height popup) (- o offset))
+
+ ;; Hide remaining lines
+ (let ((scroll-bar-char (if scroll-bar (propertize " " 'face popup-face) ""))
+ (symbol (if symbol " " "")))
+ (if (> (popup-direction popup) 0)
+ (progn
+ (when min-height
+ (while (< o min-height)
+ (popup-set-line-item popup o "" popup-face margin-left margin-right scroll-bar-char symbol "")
+ (incf o)))
+ (while (< o height)
+ (popup-hide-line popup o)
+ (incf o)))
+ (loop with h = (if min-height (- height min-height) offset)
+ for o from 0 below offset
+ if (< o h)
+ do (popup-hide-line popup o)
+ if (>= o h)
+ do (popup-set-line-item popup o "" popup-face margin-left margin-right scroll-bar-char symbol ""))))))
+
+(defun popup-hide (popup)
+ (dotimes (i (popup-height popup))
+ (popup-hide-line popup i)))
+
+(defun popup-hidden-p (popup)
+ (let ((hidden t))
+ (when (popup-live-p popup)
+ (dotimes (i (popup-height popup))
+ (unless (popup-line-hidden-p popup i)
+ (setq hidden nil))))
+ hidden))
+
+(defun popup-select (popup i)
+ (setq i (+ i (popup-offset popup)))
+ (when (and (<= 0 i) (< i (popup-height popup)))
+ (setf (popup-cursor popup) i)
+ (popup-draw popup)
+ t))
+
+(defun popup-next (popup)
+ (let ((height (popup-height popup))
+ (cursor (1+ (popup-cursor popup)))
+ (scroll-top (popup-scroll-top popup))
+ (length (length (popup-list popup))))
+ (cond
+ ((>= cursor length)
+ ;; Back to first page
+ (setq cursor 0
+ scroll-top 0))
+ ((= cursor (+ scroll-top height))
+ ;; Go to next page
+ (setq scroll-top (min (1+ scroll-top) (max (- length height) 0)))))
+ (setf (popup-cursor popup) cursor
+ (popup-scroll-top popup) scroll-top)
+ (popup-draw popup)))
+
+(defun popup-previous (popup)
+ (let ((height (popup-height popup))
+ (cursor (1- (popup-cursor popup)))
+ (scroll-top (popup-scroll-top popup))
+ (length (length (popup-list popup))))
+ (cond
+ ((< cursor 0)
+ ;; Go to last page
+ (setq cursor (1- length)
+ scroll-top (max (- length height) 0)))
+ ((= cursor (1- scroll-top))
+ ;; Go to previous page
+ (decf scroll-top)))
+ (setf (popup-cursor popup) cursor
+ (popup-scroll-top popup) scroll-top)
+ (popup-draw popup)))
+
+(defun popup-scroll-down (popup &optional n)
+ (let ((scroll-top (min (+ (popup-scroll-top popup) (or n 1))
+ (- (length (popup-list popup)) (popup-height popup)))))
+ (setf (popup-cursor popup) scroll-top
+ (popup-scroll-top popup) scroll-top)
+ (popup-draw popup)))
+
+(defun popup-scroll-up (popup &optional n)
+ (let ((scroll-top (max (- (popup-scroll-top popup) (or n 1))
+ 0)))
+ (setf (popup-cursor popup) scroll-top
+ (popup-scroll-top popup) scroll-top)
+ (popup-draw popup)))
+
+
+
+;; Popup isearch
+
+(defface popup-isearch-match
+ '((t (:background "sky blue")))
+ "Popup isearch match face."
+ :group 'popup)
+
+(defvar popup-isearch-cursor-color "blue")
+
+(defvar popup-isearch-keymap
+ (let ((map (make-sparse-keymap)))
+ ;(define-key map "\r" 'popup-isearch-done)
+ (define-key map "\C-g" 'popup-isearch-cancel)
+ (define-key map "\C-h" 'popup-isearch-delete)
+ (define-key map (kbd "DEL") 'popup-isearch-delete)
+ map))
+
+(defsubst popup-isearch-char-p (char)
+ (and (integerp char)
+ (<= 32 char)
+ (<= char 126)))
+
+(defun popup-isearch-filter-list (pattern list)
+ (loop with regexp = (regexp-quote pattern)
+ for item in list
+ do
+ (unless (stringp item)
+ (setq item (popup-item-propertize (popup-x-to-string item)
+ 'value item)))
+ if (string-match regexp item)
+ collect (let ((beg (match-beginning 0))
+ (end (match-end 0)))
+ (alter-text-property 0 (length item) 'face
+ (lambda (prop)
+ (unless (eq prop 'popup-isearch-match)
+ prop))
+ item)
+ (put-text-property beg end
+ 'face 'popup-isearch-match
+ item)
+ item)))
+
+(defun popup-isearch-prompt (popup pattern)
+ (format "Pattern: %s" (if (= (length (popup-list popup)) 0)
+ (propertize pattern 'face 'isearch-fail)
+ pattern)))
+
+(defun popup-isearch-update (popup pattern &optional callback)
+ (setf (popup-cursor popup) 0
+ (popup-scroll-top popup) 0
+ (popup-pattern popup) pattern)
+ (let ((list (popup-isearch-filter-list pattern (popup-original-list popup))))
+ (popup-set-filtered-list popup list)
+ (if callback
+ (funcall callback list)))
+ (popup-draw popup))
+
+(defun* popup-isearch (popup
+ &key
+ (cursor-color popup-isearch-cursor-color)
+ (keymap popup-isearch-keymap)
+ callback
+ help-delay)
+ (let ((list (popup-original-list popup))
+ (pattern (or (popup-pattern popup) ""))
+ (old-cursor-color (frame-parameter (selected-frame) 'cursor-color))
+ prompt key binding done)
+ (unwind-protect
+ (unless (block nil
+ (if cursor-color
+ (set-cursor-color cursor-color))
+ (while t
+ (setq prompt (popup-isearch-prompt popup pattern))
+ (setq key (popup-menu-read-key-sequence keymap prompt help-delay))
+ (if (null key)
+ (unless (funcall popup-menu-show-quick-help-function popup nil :prompt prompt)
+ (clear-this-command-keys)
+ (push (read-event prompt) unread-command-events))
+ (setq binding (lookup-key keymap key))
+ (cond
+ ((and (stringp key)
+ (popup-isearch-char-p (aref key 0)))
+ (setq pattern (concat pattern key)))
+ ((eq binding 'popup-isearch-done)
+ (return t))
+ ((eq binding 'popup-isearch-cancel)
+ (return nil))
+ ((eq binding 'popup-isearch-delete)
+ (if (> (length pattern) 0)
+ (setq pattern (substring pattern 0 (1- (length pattern))))))
+ (t
+ (setq unread-command-events
+ (append (listify-key-sequence key) unread-command-events))
+ (return t)))
+ (popup-isearch-update popup pattern callback))))
+ (popup-isearch-update popup "" callback)
+ t) ; Return non-nil if isearch is cancelled
+ (if old-cursor-color
+ (set-cursor-color old-cursor-color)))))
+
+
+
+;; Popup tip
+
+(defface popup-tip-face
+ '((t (:background "khaki1" :foreground "black")))
+ "Face for popup tip."
+ :group 'popup)
+
+(defvar popup-tip-max-width 80)
+
+(defun* popup-tip (string
+ &key
+ point
+ (around t)
+ width
+ (height 15)
+ min-height
+ truncate
+ margin
+ margin-left
+ margin-right
+ scroll-bar
+ parent
+ parent-offset
+ nowait
+ prompt
+ &aux tip lines)
+ (if (bufferp string)
+ (setq string (with-current-buffer string (buffer-string))))
+ ;; TODO strip text (mainly face) properties
+ (setq string (substring-no-properties string))
+
+ (and (eq margin t) (setq margin 1))
+ (or margin-left (setq margin-left margin))
+ (or margin-right (setq margin-right margin))
+
+ (let ((it (popup-fill-string string width popup-tip-max-width)))
+ (setq width (car it)
+ lines (cdr it)))
+
+ (setq tip (popup-create point width height
+ :min-height min-height
+ :around around
+ :margin-left margin-left
+ :margin-right margin-right
+ :scroll-bar scroll-bar
+ :face 'popup-tip-face
+ :parent parent
+ :parent-offset parent-offset))
+
+ (unwind-protect
+ (when (> (popup-width tip) 0) ; not to be corrupted
+ (when (and (not (eq width (popup-width tip))) ; truncated
+ (not truncate))
+ ;; Refill once again to lines be fitted to popup width
+ (setq width (popup-width tip))
+ (setq lines (cdr (popup-fill-string string width width))))
+
+ (popup-set-list tip lines)
+ (popup-draw tip)
+ (if nowait
+ tip
+ (clear-this-command-keys)
+ (push (read-event prompt) unread-command-events)
+ t))
+ (unless nowait
+ (popup-delete tip))))
+
+
+
+;; Popup menu
+
+(defface popup-menu-face
+ '((t (:background "lightgray" :foreground "black")))
+ "Face for popup menu."
+ :group 'popup)
+
+(defface popup-menu-selection-face
+ '((t (:background "steelblue" :foreground "white")))
+ "Face for popup menu selection."
+ :group 'popup)
+
+(defvar popup-menu-show-tip-function 'popup-tip
+ "Function used for showing tooltip by `popup-menu-show-quick-help'.")
+
+(defvar popup-menu-show-quick-help-function 'popup-menu-show-quick-help
+ "Function used for showing quick help by `popup-menu*'.")
+
+(defun popup-menu-show-help (menu &optional persist item)
+ (popup-item-show-help (or item (popup-selected-item menu)) persist))
+
+(defun popup-menu-documentation (menu &optional item)
+ (popup-item-documentation (or item (popup-selected-item menu))))
+
+(defun popup-menu-show-quick-help (menu &optional item &rest args)
+ (let* ((point (plist-get args :point))
+ (height (or (plist-get args :height) (popup-height menu)))
+ (min-height (min height (popup-current-height menu)))
+ (around nil)
+ (parent-offset (popup-offset menu))
+ (doc (popup-menu-documentation menu item)))
+ (when (stringp doc)
+ (if (popup-hidden-p menu)
+ (setq around t
+ menu nil
+ parent-offset nil)
+ (setq point nil))
+ (let ((popup-use-optimized-column-computation nil)) ; To avoid wrong positioning
+ (apply popup-menu-show-tip-function
+ doc
+ :point point
+ :height height
+ :min-height min-height
+ :around around
+ :parent menu
+ :parent-offset parent-offset
+ args)))))
+
+(defun popup-menu-read-key-sequence (keymap &optional prompt timeout)
+ (catch 'timeout
+ (let ((timer (and timeout
+ (run-with-timer timeout nil
+ (lambda ()
+ (if (zerop (length (this-command-keys)))
+ (throw 'timeout nil))))))
+ (old-global-map (current-global-map))
+ (temp-global-map (make-sparse-keymap))
+ (overriding-terminal-local-map (make-sparse-keymap)))
+ (substitute-key-definition 'keyboard-quit 'keyboard-quit
+ temp-global-map old-global-map)
+ (define-key temp-global-map [menu-bar] (lookup-key old-global-map [menu-bar]))
+ (define-key temp-global-map [tool-bar] (lookup-key old-global-map [tool-bar]))
+ (set-keymap-parent overriding-terminal-local-map keymap)
+ (if (current-local-map)
+ (define-key overriding-terminal-local-map [menu-bar]
+ (lookup-key (current-local-map) [menu-bar])))
+ (unwind-protect
+ (progn
+ (use-global-map temp-global-map)
+ (clear-this-command-keys)
+ (with-temp-message prompt
+ (read-key-sequence nil)))
+ (use-global-map old-global-map)
+ (if timer (cancel-timer timer))))))
+
+(defun popup-menu-fallback (event default))
+
+(defun* popup-menu-event-loop (menu keymap fallback &optional prompt help-delay isearch isearch-cursor-color isearch-keymap isearch-callback &aux key binding)
+ (block nil
+ (while (popup-live-p menu)
+ (and isearch
+ (popup-isearch menu
+ :cursor-color isearch-cursor-color
+ :keymap isearch-keymap
+ :callback isearch-callback
+ :help-delay help-delay)
+ (keyboard-quit))
+ (setq key (popup-menu-read-key-sequence keymap prompt help-delay))
+ (if (null key)
+ (unless (funcall popup-menu-show-quick-help-function menu nil :prompt prompt)
+ (clear-this-command-keys)
+ (push (read-event prompt) unread-command-events))
+ (if (eq (lookup-key (current-global-map) key) 'keyboard-quit)
+ (keyboard-quit))
+ (setq binding (lookup-key keymap key))
+ (cond
+ ((eq binding 'popup-close)
+ (if (popup-parent menu)
+ (return)))
+ ((memq binding '(popup-select popup-open))
+ (let* ((item (popup-selected-item menu))
+ (sublist (popup-item-sublist item)))
+ (if sublist
+ (popup-aif (popup-cascade-menu sublist
+ :around nil
+ :parent menu
+ :margin-left (popup-margin-left menu)
+ :margin-right (popup-margin-right menu)
+ :scroll-bar (popup-scroll-bar menu))
+ (and it (return it)))
+ (if (eq binding 'popup-select)
+ (return (popup-item-value-or-self item))))))
+ ((eq binding 'popup-next)
+ (popup-next menu))
+ ((eq binding 'popup-previous)
+ (popup-previous menu))
+ ((eq binding 'popup-help)
+ (popup-menu-show-help menu))
+ ((eq binding 'popup-isearch)
+ (popup-isearch menu
+ :cursor-color isearch-cursor-color
+ :keymap isearch-keymap
+ :callback isearch-callback
+ :help-delay help-delay))
+ ((commandp binding)
+ (call-interactively binding))
+ (t
+ (funcall fallback key (key-binding key))))))))
+
+;; popup-menu is used by mouse.el unfairly...
+(defun* popup-menu* (list
+ &key
+ point
+ (around t)
+ (width (popup-preferred-width list))
+ (height 15)
+ margin
+ margin-left
+ margin-right
+ scroll-bar
+ symbol
+ parent
+ parent-offset
+ (keymap popup-menu-keymap)
+ (fallback 'popup-menu-fallback)
+ help-delay
+ prompt
+ isearch
+ (isearch-cursor-color popup-isearch-cursor-color)
+ (isearch-keymap popup-isearch-keymap)
+ isearch-callback
+ &aux menu event)
+ (and (eq margin t) (setq margin 1))
+ (or margin-left (setq margin-left margin))
+ (or margin-right (setq margin-right margin))
+ (if (and scroll-bar
+ (integerp margin-right)
+ (> margin-right 0))
+ ;; Make scroll-bar space as margin-right
+ (decf margin-right))
+ (setq menu (popup-create point width height
+ :around around
+ :face 'popup-menu-face
+ :selection-face 'popup-menu-selection-face
+ :margin-left margin-left
+ :margin-right margin-right
+ :scroll-bar scroll-bar
+ :symbol symbol
+ :parent parent))
+ (unwind-protect
+ (progn
+ (popup-set-list menu list)
+ (popup-draw menu)
+ (popup-menu-event-loop menu keymap fallback prompt help-delay isearch
+ isearch-cursor-color isearch-keymap isearch-callback))
+ (popup-delete menu)))
+
+(defun popup-cascade-menu (list &rest args)
+ "Same to `popup-menu', but an element of `LIST' can be
+list of submenu."
+ (apply 'popup-menu*
+ (mapcar (lambda (item)
+ (if (consp item)
+ (popup-make-item (car item)
+ :sublist (cdr item)
+ :symbol ">")
+ item))
+ list)
+ :symbol t
+ args))
+
+(defvar popup-menu-keymap
+ (let ((map (make-sparse-keymap)))
+ (define-key map "\r" 'popup-select)
+ (define-key map "\C-f" 'popup-open)
+ (define-key map [right] 'popup-open)
+ (define-key map "\C-b" 'popup-close)
+ (define-key map [left] 'popup-close)
+
+ (define-key map "\C-n" 'popup-next)
+ (define-key map [down] 'popup-next)
+ (define-key map "\C-p" 'popup-previous)
+ (define-key map [up] 'popup-previous)
+
+ (define-key map [f1] 'popup-help)
+ (define-key map (kbd "\C-?") 'popup-help)
+
+ (define-key map "\C-s" 'popup-isearch)
+ map))
+
+(provide 'popup)
+;;; popup.el ends here
View
57 extensions/cython-mode.el
@@ -0,0 +1,57 @@
+;; Cython mode
+(require 'python)
+
+(defun cython-compile ()
+ "Compile the file via Cython."
+ (interactive)
+ (let ((cy-buffer (current-buffer)))
+ (with-current-buffer
+ (compile compile-command)
+ (set (make-local-variable 'cython-buffer) cy-buffer)
+ (add-to-list (make-local-variable 'compilation-finish-functions)
+ 'cython-compilation-finish)))
+ )
+
+(defun cython-compilation-finish (buffer how)
+ "Called when Cython compilation finishes."
+ ;; XXX could annotate source here
+ )
+
+(defvar cython-mode-map
+ (let ((map (make-sparse-keymap)))
+ ;; Will inherit from `python-mode-map' thanks to define-derived-mode.
+ (define-key map "\C-c\C-c" 'cython-compile)
+ map)
+ "Keymap used in `cython-mode'.")
+
+(defvar cython-font-lock-keywords
+ `(;; new keywords in Cython language
+ (,(regexp-opt '("by" "cdef" "cimport" "cpdef" "ctypedef" "enum" "except?"
+ "extern" "gil" "include" "nogil" "property" "public"
+ "readonly" "struct" "union" "DEF" "IF" "ELIF" "ELSE") 'words)
+ 1 font-lock-keyword-face)
+ ;; C and Python types (highlight as builtins)
+ (,(regexp-opt '("NULL" "bint" "char" "dict" "double" "float" "int" "list"
+ "long" "object" "Py_ssize_t" "short" "size_t" "void") 'words)
+ 1 font-lock-builtin-face)
+ ;; cdef is used for more than functions, so simply highlighting the next
+ ;; word is problematic. struct, enum and property work though.
+ ("\\<\\(?:struct\\|enum\\)[ \t]+\\([a-zA-Z_]+[a-zA-Z0-9_]*\\)"
+ 1 py-class-name-face)
+ ("\\<property[ \t]+\\([a-zA-Z_]+[a-zA-Z0-9_]*\\)"
+ 1 font-lock-function-name-face))
+ "Additional font lock keywords for Cython mode.")
+
+(define-derived-mode cython-mode python-mode "Cython"
+ "Major mode for Cython development, derived from Python mode.
+
+\\{cython-mode-map}"
+ (setcar font-lock-defaults
+ (append python-font-lock-keywords cython-font-lock-keywords))
+ (set (make-local-variable 'compile-command)
+ (concat "cython -a " buffer-file-name))
+ (add-to-list (make-local-variable 'compilation-finish-functions)
+ 'cython-compilation-finish)
+)
+
+(provide 'cython-mode)
View
16 extensions/emacs-dbgr/.gitignore
@@ -0,0 +1,16 @@
+/*.elc
+/*.tar.gz
+/*~
+/COPYING
+/Makefile
+/Makefile.in
+/README
+/aclocal.m4
+/autom4te.cache
+/config.log
+/config.status
+/configure
+/elc-stamp
+/elc-temp
+/install-sh
+/missing
View
1 extensions/emacs-dbgr/AUTHORS
@@ -0,0 +1 @@
+rocky@gnu.org
View
1,019 extensions/emacs-dbgr/ChangeLog
@@ -0,0 +1,1019 @@
+2010-05-06 rocky <rocky@gnu.org>
+
+ * dbgr/common/init/bashdb.el, dbgr/common/init/kshdb.el,
+ dbgr/common/init/pydbgr.el, dbgr/common/init/rbdbgr.el,
+ test/Makefile.am, test/test-dbgr.el, test/test-regexp-rbdbgr.el:
+ common/init/rbdbgr.el: prompt pattern has changed Makefile.am:
+ wasn't testing rbdbgr reset: Add more provide's in init files.
+
+2010-03-20 rocky <rockyb@rubyforge.org>
+
+ * dbgr/pydbgr/Makefile.am: Forgot one python->pydbgr
+
+2010-03-19 R. Bernstein <rocky@gnu.org>
+
+ * dbgr.el, dbgr/gdb/gdb.el, dbgr/pydbgr/pydbgr.el,
+ dbgr/rbdbgr/rbdbgr.el, dbgr/rdebug/rdebug.el: Add "dbgr-" prefix to
+ keep namespace separate from other standalones, e.g. dbg-gdb vs gdb.
+
+2010-03-19 rocky <rockyb@rubyforge.org>
+
+ * configure.ac: One more python->pydbgr
+
+2010-03-19 R. Bernstein <rocky@gnu.org>
+
+ * dbgr.el, dbgr/Makefile.am, dbgr/gdb/core.el,
+ dbgr/gdb/gdb-core.el, dbgr/gdb/gdb-track-mode.el, dbgr/gdb/gdb.el,
+ dbgr/gdb/track-mode.el, dbgr/pydbgr/.gitignore,
+ dbgr/pydbgr/Makefile.am, dbgr/pydbgr/core.el,
+ dbgr/pydbgr/pydbgr.el, dbgr/pydbgr/track-mode.el,
+ dbgr/python/.gitignore, dbgr/python/Makefile.am,
+ dbgr/python/pydbgr-core.el, dbgr/python/pydbgr-track-mode.el,
+ dbgr/python/pydbgr.el, test/Makefile.am,
+ test/test-regexp-pydbgr.el, test/test-regexp-python.el: directory
+ python -> pydbgr. Debugger-specific file anme simplifications.
+
+2010-03-19 R. Bernstein <rocky@gnu.org>
+
+ * configure.ac, dbgr.el, dbgr/Makefile.am, dbgr/bp.el,
+ dbgr/buffer.el, dbgr/cmdbuf.el, dbgr/cmds.el,
+ dbgr/common/.gitignore, dbgr/common/Makefile.am, dbgr/common/bp.el,
+ dbgr/common/buffer.el, dbgr/common/cmdbuf.el, dbgr/common/cmds.el,
+ dbgr/common/core.el, dbgr/common/custom.el, dbgr/common/file.el,
+ dbgr/common/fringe.el, dbgr/common/helper.el, dbgr/common/init.el,
+ dbgr/common/init/.gitignore, dbgr/common/init/Makefile.am,
+ dbgr/common/init/bashdb.el, dbgr/common/init/gdb.el,
+ dbgr/common/init/kshdb.el, dbgr/common/init/pydb.el,
+ dbgr/common/init/pydbgr.el, dbgr/common/init/rbdbgr.el,
+ dbgr/common/init/rdebug.el, dbgr/common/init/remake.el,
+ dbgr/common/init/zshdb.el, dbgr/common/key.el, dbgr/common/loc.el,
+ dbgr/common/lochist.el, dbgr/common/menu.el, dbgr/common/regexp.el,
+ dbgr/common/reset.el, dbgr/common/send.el, dbgr/common/shortkey.el,
+ dbgr/common/srcbuf.el, dbgr/common/track-mode.el,
+ dbgr/common/track.el, dbgr/common/window.el, dbgr/core.el,
+ dbgr/custom.el, dbgr/file.el, dbgr/fringe.el, dbgr/gdb/gdb-core.el,
+ dbgr/gdb/gdb-track-mode.el, dbgr/gdb/gdb.el, dbgr/helper.el,
+ dbgr/init.el, dbgr/init/.gitignore, dbgr/init/Makefile.am,
+ dbgr/init/bashdb.el, dbgr/init/gdb.el, dbgr/init/kshdb.el,
+ dbgr/init/pydb.el, dbgr/init/pydbgr.el, dbgr/init/rbdbgr.el,
+ dbgr/init/rdebug.el, dbgr/init/remake.el, dbgr/init/zshdb.el,
+ dbgr/key.el, dbgr/loc.el, dbgr/lochist.el, dbgr/menu.el,
+ dbgr/python/pydbgr-core.el, dbgr/python/pydbgr-track-mode.el,
+ dbgr/python/pydbgr.el, dbgr/rbdbgr/cmds.el, dbgr/rbdbgr/core.el,
+ dbgr/rbdbgr/rbdbgr.el, dbgr/rbdbgr/track-mode.el,
+ dbgr/rdebug/cmds.el, dbgr/rdebug/core.el, dbgr/rdebug/rdebug.el,
+ dbgr/rdebug/track-mode.el, dbgr/regexp.el, dbgr/reset.el,
+ dbgr/send.el, dbgr/shortkey.el, dbgr/srcbuf.el, dbgr/track-mode.el,
+ dbgr/track.el, dbgr/window.el, test/test-bp.el,
+ test/test-cmdbuf.el, test/test-core.el, test/test-file.el,
+ test/test-helper.el, test/test-loc.el, test/test-lochist.el,
+ test/test-regexp-gdb.el, test/test-regexp-python.el,
+ test/test-regexp-rbdbgr.el, test/test-regexp-rdebug.el,
+ test/test-regexp.el, test/test-send.el, test/test-shortkey.el,
+ test/test-srcbuf.el, test/test-track.el: All common code now pushed
+ to common directory one level don. First part an overall filesystem
+ reorganization. Later on we will remove init, and rename python to
+ pydbgr, and add pydb.
+
+2010-03-13 rocky <rockyb@rubyforge.org>
+
+ * dbgr/key.el, dbgr/lochist.el, dbgr/rdebug/.gitignore,
+ dbgr/rdebug/Makefile: key.el: add key to set breakpoints lochist.el:
+ larger default history ring .gitignore, Makefile: is derived from
+ Makefile.am
+
+2010-03-12 R. Bernstein <rocky@gnu.org>
+
+ * dbgr/gdb/gdb-track-mode.el, dbgr/python/pydbgr-track-mode.el,
+ dbgr/rbdbgr/track-mode.el, dbgr/rdebug/track-mode.el,
+ test/Makefile.am, test/test-track-mode.el, test/test-track.el: Base
+ the specific debugger track-mode-maps on the generic track-mode map.
+ Start a track-mode unit test.
+
+2010-03-04 R. Bernstein <rocky@gnu.org>
+
+ * configure.ac, dbgr.el, dbgr/Makefile.am, dbgr/init/rdebug.el,
+ dbgr/rbdbgr/.gitignore, dbgr/rbdbgr/Makefile.am,
+ dbgr/rbdbgr/cmds.el, dbgr/rbdbgr/core.el, dbgr/rbdbgr/rbdbgr.el,
+ dbgr/rbdbgr/track-mode.el, dbgr/rdebug/.gitignore,
+ dbgr/rdebug/Makefile, dbgr/rdebug/Makefile.am, dbgr/rdebug/cmds.el,
+ dbgr/rdebug/core.el, dbgr/rdebug/elc-stamp, dbgr/rdebug/rdebug.el,
+ dbgr/rdebug/track-mode.el, dbgr/ruby/.gitignore,
+ dbgr/ruby/Makefile.am, dbgr/ruby/cmds.el, dbgr/ruby/core.el,
+ dbgr/ruby/rbdbgr.el, dbgr/ruby/track-mode.el, test/test-core.el:
+ Start rdebug. Will probably reorganize directories down the line.
+
+2010-01-31 rocky <rockyb@rubyforge.org>
+
+ * dbgr/cmdbuf.el, dbgr/cmds.el, dbgr/key.el, dbgr/menu.el,
+ dbgr/ruby/core.el, dbgr/ruby/rbdbgr.el, dbgr/ruby/track-mode.el,
+ dbgr/track.el, test/test-core.el: Move forward on breakpoints. Add
+ breakpoint list to cmdbuf and menu items for breakpoint track.el Reduce use of depreciated fields in cmdbuf ruby/*.el: simplify names.
+
+2010-01-31 rocky <rockyb@rubyforge.org>
+
+ * dbgr/ruby/cmds.el, dbgr/ruby/core.el, dbgr/ruby/rbdbgr-core.el,
+ dbgr/ruby/rbdbgr-track-mode.el, dbgr/ruby/track-mode.el: Move
+ forward towards handling breakpoints: Keep a list of breakpoints in
+ cmdbuf, add menu item to set a breakpoint ruby/*: simplify names track.el: reduce use of depricated loc-regex,
+ file-group, line-group fields.
+
+2010-01-30 rocky <rockyb@rubyforge.org>
+
+ * dbgr/cmdbuf.el, dbgr/init/rbdbgr.el, dbgr/track.el: Start to
+ remove dbgr-cmdbuf-info loc-regexp, file-group and line-group. Add
+ pat for in rbdbgr a deleted breakpoint.
+
+2010-01-27 rocky <rocky@gnu.org>
+
+ * dbgr.el: dbr.el: dbgr-loaded-features is a command.
+
+2010-01-27 R. Bernstein <rocky@gnu.org>
+
+ * dbgr.el, dbgr/bp.el, test/Makefile.am, test/test-bp.el,
+ test/test-dbgr.el: dbgr.el test-dbgr.el: Add ability to get list of
+ feature loaded with dbgr and unload them. This makes it possible to
+ reload dbgr without leaving the Emacs. bp.el: More work needed on
+ testing.
+
+2010-01-27 rocky <rocky@gnu.org>
+
+ * dbgr/core.el, dbgr/gdb/gdb.el, dbgr/python/pydbgr.el,
+ dbgr/reset.el, dbgr/ruby/rbdbgr.el: Add reset by default to
+ dbg-exec-shell.
+
+2010-01-26 rocky <rocky@gnu.org>
+
+ * dbgr/reset.el: Start a reset routine.
+
+2010-01-26 rocky <rockyb@rubyforge.org>
+
+ * dbgr/cmdbuf.el, dbgr/track.el, test/test-cmdbuf.el,
+ test/test-track.el: cmdbuf.el: Save source buffers associated with a
+ given command buffer. track.el: ditto. dbgr-track-from-region():
+ check that cmdbuf is a cmdbuf.
+
+2010-01-24 rocky <rockyb@rubyforge.org>
+
+ * dbgr/core.el, dbgr/gdb/gdb.el: gdb.el: expand script filename.
+ core.el: docstring fix.
+
+2010-01-24 rocky <rockyb@rubyforge.org>
+
+ * dbgr.el, dbgr/gdb/.gitignore, dbgr/init/gdb.el, dbgr/loc.el,
+ dbgr/regexp.el: Add fields for address, and character offset.
+
+2010-01-21 R. Bernstein <rocky@gnu.org>
+
+ * dbgr/gdb/gdb-track-mode.el, dbgr/track.el: Tolerate missing source
+ file. Need to do better though between file.el:
+ dbgr-file-loc-from-line and dbgr/track.el
+
+2010-01-20 rocky <rockyb@rubyforge.org>
+
+ * configure.ac: Administrivia
+
+2010-01-20 rocky <rockyb@rubyforge.org>
+
+ * dbgr/Makefile.am, dbgr/gdb/.gitignore, dbgr/gdb/Makefile.am,
+ dbgr/gdb/gdb-core.el, dbgr/gdb/gdb-track-mode.el, dbgr/gdb/gdb.el:
+ Fill out more gdb interaction via dbgr.
+
+2010-01-18 rocky <rockyb@rubyforge.org>
+
+ * dbgr/loc.el, test/test-regexp-gdb.el: loc.el: add place holder for
+ column number test-regexp-gdb.el: start unit test for gdb.
+
+2010-01-18 R. Bernstein <rocky@gnu.org>
+
+ * dbgr/init/gdb.el: Start gdb mode.
+
+2010-01-09 rocky <rockyb@rubyforge.org>
+
+ * dbgr/bp.el, dbgr/track.el, test/test-track.el: Breakpont fixes.
+ Show only one breakpoint icon in margin. Store breakpoint number as
+ a number, not a string. Show breakpoint in help string. Add a
+ dbgr-track-bp-loc test.
+
+2010-01-02 rocky <rockyb@rubyforge.org>
+
+ * dbgr/init/bashdb.el, dbgr/init/kshdb.el, dbgr/init/zshdb.el: Add
+ breakpoint tracking regexp.
+
+2010-01-01 rocky <rocky@gnu.org>
+
+ * dbgr/init/rdebug.el: Add breakpoint regexp for rdebug.
+
+2010-01-01 rocky <rocky@gnu.org>
+
+ * test/test-regexp-rbdbgr.el, test/test-regexp-rdebug.el,
+ test/test-regexp-ruby.el: Add breakpoint tracking for rdebug.
+
+2010-01-01 rocky <rocky@gnu.org>
+
+ * test/Makefile: Makefile is derived
+
+2010-01-01 rocky <rockyb@rubyforge.org>
+
+ * dbgr/track.el: Remove erroneous message.
+
+2010-01-01 rocky <rockyb@rubyforge.org>
+
+ * dbgr/bp.el, dbgr/file.el, dbgr/init/rbdbgr.el, dbgr/loc.el,
+ dbgr/regexp.el, dbgr/track.el, test/test-bp.el,
+ test/test-regexp-ruby.el, test/test-track.el: Attempt to move
+ forward in tracking breakpoints setting.
+
+2009-12-28 rocky <rockyb@rubyforge.org>
+
+ * dbgr/bp.el, dbgr/brkpt.el: Add breakpoint handling test.
+
+2009-12-28 rocky <rockyb@rubyforge.org>
+
+ * dbgr/brkpt.el: More display/remove cleanup.
+
+2009-12-27 rocky <rockyb@rubyforge.org>
+
+ * dbgr/brkpt.el: Small improvements (?) towards getting breakpoint
+ icons working.
+
+2009-12-27 rocky <rockyb@rubyforge.org>
+
+ * Makefile.am, configure.ac, dbgr/Makefile.am, dbgr/brkpt.el,
+ dbgr/fringe.el, test/.gitignore, test/Makefile, test/Makefile.am:
+ Start working on breakpoint icons. "make test" works inside dbgr
+ directory.
+
+2009-12-22 rocky <rockyb@rubyforge.org>
+
+ * dbgr/cmds.el, dbgr/send.el, dbgr/window.el, test/test-send.el:
+ Some debugger commands prompt. So we need to make sure we show the
+ command buffer for those.
+
+2009-12-21 rocky <rockyb@rubyforge.org>
+
+ * dbgr/cmds.el, dbgr/custom.el, dbgr/key.el, dbgr/menu.el,
+ dbgr/shortkey.el: Get menus under control. Works now in "short-key"
+ mode. Help is provided too!
+
+2009-12-20 rocky <rockyb@rubyforge.org>
+
+ * dbgr/buffer.el, dbgr/cmds.el, dbgr/menu.el,
+ dbgr/ruby/rbdbgr-track-mode.el, dbgr/shortkey.el,
+ dbgr/track-mode.el: Start to add menu commands. gdb command "finish"
+ added.
+
+2009-12-18 rocky <rocky@gnu.org>
+
+ * autogen.sh: Don't overwrite elisp-comp.
+
+2009-12-16 rocky <rockyb@rubyforge.org>
+
+ * dbgr/loc.el: Use loc-changes-goto of new package loc-changes to
+ find line number positions. loc-changes-goto is more tolerant of
+ buffer modifications.
+
+2009-12-16 rocky <rockyb@rubyforge.org>
+
+ * .gitignore, Makefile.am, buffer.el, cmdbuf.el, cmds.el,
+ configure.ac, core.el, custom.el, dbgr.el, dbgr/.gitignore,
+ dbgr/Makefile.am, dbgr/buffer.el, dbgr/cmdbuf.el, dbgr/cmds.el,
+ dbgr/core.el, dbgr/custom.el, dbgr/file.el, dbgr/fringe.el,
+ dbgr/helper.el, dbgr/init.el, dbgr/init/.gitignore,
+ dbgr/init/Makefile.am, dbgr/init/bashdb.el, dbgr/init/kshdb.el,
+ dbgr/init/pydb.el, dbgr/init/pydbgr.el, dbgr/init/rbdbgr.el,
+ dbgr/init/rdebug.el, dbgr/init/remake.el, dbgr/init/zshdb.el,
+ dbgr/key.el, dbgr/loc.el, dbgr/lochist.el, dbgr/python/.gitignore,
+ dbgr/python/Makefile.am, dbgr/python/pydbgr-core.el,
+ dbgr/python/pydbgr-track-mode.el, dbgr/python/pydbgr.el,
+ dbgr/regexp.el, dbgr/ruby/.gitignore, dbgr/ruby/Makefile.am,
+ dbgr/ruby/rbdbgr-core.el, dbgr/ruby/rbdbgr-track-mode.el,
+ dbgr/ruby/rbdbgr.el, dbgr/send.el, dbgr/shortkey.el,
+ dbgr/srcbuf.el, dbgr/track-mode.el, dbgr/track.el, dbgr/window.el,
+ file.el, fringe.el, helper.el, init.el, init/.gitignore,
+ init/Makefile.am, init/bashdb.el, init/kshdb.el, init/pydb.el,
+ init/pydbgr.el, init/rbdbgr.el, init/rdebug.el, init/remake.el,
+ init/zshdb.el, key.el, loc.el, lochist.el, python/.gitignore,
+ python/Makefile.am, python/pydbgr-core.el,
+ python/pydbgr-track-mode.el, python/pydbgr.el, regexp.el,
+ ruby/.gitignore, ruby/Makefile.am, ruby/rbdbgr-core.el,
+ ruby/rbdbgr-track-mode.el, ruby/rbdbgr.el, send.el, shortkey.el,
+ srcbuf.el, test/test-cmdbuf.el, test/test-core.el,
+ test/test-file.el, test/test-helper.el, test/test-loc.el,
+ test/test-lochist.el, test/test-regexp-python.el,
+ test/test-regexp-ruby.el, test/test-regexp.el, test/test-send.el,
+ test/test-shortkey.el, test/test-srcbuf.el, test/test-track.el,
+ track-mode.el, track.el, window.el: dbgr.el - loads everything (via
+ load-relative). Push dbgr source files into dbgr which is where
+ they are installed. Cleaner this way.
+