Mercurial > emacs
view lisp/progmodes/sym-comp.el @ 92870:8f17f65dd575
* textmodes/org.el (org-ctrl-c-star): Implement a missing branch
in the decision tree.
(org-select-remember-template): Cleaned the code.
(org-prepare-dblock): Added the extra :content parameter.
(org-write-agenda): New output type ".ics" files.
(org-write-agenda): Call `org-icalendar-verify-function', both for
time stamps and for TODO entries.
(org-agenda-collect-markers, org-create-marker-find-array)
(org-check-agenda-marker-table): New functions.
(org-agenda-marker-table): New variable.
(org-export-as-html): Revert the change that killed the html
buffer. Side effects first need to be studied carefully.
(org-get-tags-at): Fix the structure of the condition-case
statement.
(org-ts-regexp0, org-repeat-re, org-display-custom-time)
(org-timestamp-change): Fix regulear expressions to swallow the
extra character for repeat-shift control.
(org-auto-repeat-maybe): Implement the new repeater mechanisms.
(org-get-legal-level): Aliased to `org-get-valid-level'.
(org-dblock-write:clocktable): Added a :link parameter, linking
headlines to their location in the Org agenda files.
(org-get-tags-at): Bugfix: prevent `org-back-to-heading' from
throwing an error when getting tags before headlines.
(org-timestamp-change, org-modify-ts-extra)
(org-ts-regexp1): Fix timestamp editing.
(org-agenda-custom-commands-local-options): New constant.
(org-agenda-custom-commands): Use
`org-agenda-custom-commands-local-options' to improve customize
type. "htmlize": Removed hack to fix face problem with htmlize,
it no longer seem necessary.
(org-follow-link-hook): New hook.
(org-agenda-custom-commands): Added "Component" as a tag for each
item in a command serie.
(org-open-at-point): Run `org-follow-link-hook'.
(org-agenda-schedule): Bugfix: don't display marker type when it
is `nil'.
(org-store-link): org-irc required.
(org-set-regexps-and-options): Parse the new logging options.
(org-extract-log-state-settings): New function.
(org-todo): Handle the new ways of recording state change stuff.
(org-local-logging): New function.
(org-columns-open-link): Fixed bug with opening link in column
view.
(org-local-logging): New function
(org-todo): Make sure that LOGGING properties are honoured.
(org-todo-keywords): Improve docstring.
(org-startup-options): Cleanup startup options.
(org-set-regexps-and-options): Process the "!" markers.
(org-todo): Respect the new logging stuff.
(org-log-note-how): New variable.
(org-add-log-maybe): New parameter HOW that defines how logging
should be done and also overrides PURPOSE. Add a docstring.
(org-add-log-note): Check if we really need to ask for a note.
(org-get-current-options): Digest the new keyword.
(org-agenda-reset-markers): Renamed from
`org-agenda-maybe-reset-markers'. FORCE argument removed.
(org-diary, org-agenda-quit, org-prepare-agenda): Call the renamed
function, without force argument.
(org-buffer-property-keys): Bind local variables s and p.
(org-make-tags-matcher): Allow "" to match an empty or
non-existent property value.
(org-export-as-html): Join unsorted lists when they directly
follow each other. Such lists may be created by headlines that
are converted to lists.
(org-nofm-to-completion): New function.
(org-export-as-html): Use :html-extension instead of
org-export-html-extension.
(org-store-link): Support for links from `rmail-summary-mode'.
(org-columns-new, org-complete, org-set-property): Set the
`include-columns' argument in the call to
`org-buffer-property-keys'.
(org-buffer-property-keys): New argument `include-columns', to
include properties expected by any of the COLUMS formats in the
current buffer.
(org-cleaned-string-for-export): Get rid of drawers first, so that
they will be removed also in the text before the first headline.
(org-clock-report): Show the clocktable when found.
(org-refile): Fix positioning bug when `org-reverse-note-order' is
nil.
(org-version): With prefix argument, insert `org-version' at
point.
(org-agenda-goto): Recenter the window after finding the target
location, to make sure the correct position will be displayed.
(org-agenda-get-deadlines): Don't scale priority with the warning
period.
(org-insert-heading): Don't break line in the middle of the line.
(org-agenda-get-deadlines): Allow `org-deadline-warning-days' to
be 0.
(org-update-checkbox-count): Revamped to deal with hierarchical
beckboxes. This was a patch from Miguel A. Figueroa-Villanueva.
(org-remove-timestamp-with-keyword): New function.
(org-schedule, org-deadline): Use
`org-remove-timestamp-with-keyword' to make sure all such time
stamps are removed.
(org-mode): Support for `align'.
(org-agenda-get-deadlines): Make sure priorities increase as the
due date approaches and is passed.
(org-remember-apply-template): Fixed problem with tags that
contain "_" or "@".
(org-make-link-regexps): Improve the regular expression for plain
links.
(org-agenda-get-closed): List each clocking entry.
(org-set-tags): Only tabify before tags if indent-tabs-mode is t.
(org-special-ctrl-k): New option.
(org-kill-line): New function.
(org-archive-all-done): Fixed incorrect number of stars in regexp.
(org-refile-get-location): New function.
(org-refile-goto-last-stored): New function.
(org-global-tags-completion-table): Add the value of org-tag-alist
in each buffer, to make sure that also unused tags will be
available for completion.
(org-columns-edit-value)
(org-columns-next-allowed-value): Only update if not in agenda.
(org-clocktable-steps): New function.
(org-dblock-write:clocktable): Call `org-clocktable-steps'.
(org-archive-subtree): Add the outline tree context as a property.
(org-closest-date): New optional argument `prefer'.
(org-goto-auto-isearch): New option.
(org-goto-map, org-get-location): Implement auto-isearch.
(org-goto-local-auto-isearch-map): New variable.
(org-goto-local-search-forward-headings)
(org-goto-local-auto-isearch): New functions
author | Carsten Dominik <dominik@science.uva.nl> |
---|---|
date | Thu, 13 Mar 2008 08:54:11 +0000 |
parents | bae32624018f |
children | 52b7a8c22af5 |
line wrap: on
line source
;;; sym-comp.el --- mode-dependent symbol completion ;; Copyright (C) 2004, 2008 Free Software Foundation, Inc. ;; Author: Dave Love <fx@gnu.org> ;; Keywords: extensions ;; URL: http://www.loveshack.ukfsn.org/emacs ;; This file is part of GNU Emacs. ;; GNU Emacs 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, or (at your option) ;; any later version. ;; GNU Emacs 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 GNU Emacs; see the file COPYING. If not, write to the ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, ;; Boston, MA 02110-1301, USA. ;;; Commentary: ;; This defines `symbol-complete', which is a generalization of the ;; old `lisp-complete-symbol'. It provides the following hooks to ;; allow major modes to set up completion appropriate for the mode: ;; `symbol-completion-symbol-function', ;; `symbol-completion-completions-function', ;; `symbol-completion-predicate-function', ;; `symbol-completion-transform-function'. Typically it is only ;; necessary for a mode to set ;; `symbol-completion-completions-function' locally and to bind ;; `symbol-complete' appropriately. ;; It's unfortunate that there doesn't seem to be a good way of ;; combining this with `complete-symbol'. ;; There is also `symbol-completion-try-complete', for use with ;; Hippie-exp. ;;; Code: ;;;; Mode-dependent symbol completion. (defun symbol-completion-symbol () "Default `symbol-completion-symbol-function'. Uses `current-word' with the buffer narrowed to the part before point." (save-restriction ;; Narrow in case point is in the middle of a symbol -- we want ;; just the preceeding part. (narrow-to-region (point-min) (point)) (current-word))) (defvar symbol-completion-symbol-function 'symbol-completion-symbol "Function to return a partial symbol before point for completion. The value it returns should be a string (or nil). Major modes may set this locally if the default isn't appropriate.") (defvar symbol-completion-completions-function nil "Function to return possible symbol completions. It takes an argument which is the string to be completed and returns a value suitable for the second argument of `try-completion'. This value need not use the argument, i.e. it may be all possible completions, such as `obarray' in the case of Emacs Lisp. Major modes may set this locally to allow them to support `symbol-complete'. See also `symbol-completion-symbol-function', `symbol-completion-predicate-function' and `symbol-completion-transform-function'.") (defvar symbol-completion-predicate-function nil "If non-nil, function to return a predicate for selecting symbol completions. The function gets two args, the positions of the beginning and end of the symbol to be completed. Major modes may set this locally if the default isn't appropriate. This is a function returning a predicate so that the predicate can be context-dependent, e.g. to select only function names if point is at a function call position. The function's args may be useful for determining the context.") (defvar symbol-completion-transform-function nil "If non-nil, function to transform symbols in the symbol-completion buffer. E.g., for Lisp, it may annotate the symbol as being a function, not a variable. The function takes the symbol name as argument. If it needs to annotate this, it should return a value suitable as an element of the list passed to `display-completion-list'. The predicate being used for selecting completions (from `symbol-completion-predicate-function') is available dynamically-bound as `symbol-completion-predicate' in case the transform needs it.") (defvar displayed-completions) ;;;###autoload (defun symbol-complete (&optional predicate) "Perform completion of the symbol preceding point. This is done in a way appropriate to the current major mode, perhaps by interrogating an inferior interpreter. Compare `complete-symbol'. If no characters can be completed, display a list of possible completions. Repeating the command at that point scrolls the list. When called from a program, optional arg PREDICATE is a predicate determining which symbols are considered. This function requires `symbol-completion-completions-function' to be set buffer-locally. Variables `symbol-completion-symbol-function', `symbol-completion-predicate-function' and `symbol-completion-transform-function' are also consulted." (interactive) ;; Fixme: Punt to `complete-symbol' in this case? (unless (functionp symbol-completion-completions-function) (error "symbol-completion-completions-function not defined")) (let ((window (get-buffer-window "*Completions*"))) (let* ((pattern (or (funcall symbol-completion-symbol-function) (error "No preceding symbol to complete"))) (predicate (or predicate (if symbol-completion-predicate-function (funcall symbol-completion-predicate-function (- (point) (length pattern)) (point))))) (completions (funcall symbol-completion-completions-function pattern)) (completion (try-completion pattern completions predicate))) ;; If this command was repeated, and there's a fresh completion ;; window with a live buffer and a displayed completion list ;; matching the current completions, then scroll the window. (unless (and (eq last-command this-command) window (window-live-p window) (window-buffer window) (buffer-name (window-buffer window)) (with-current-buffer (window-buffer window) (if (equal displayed-completions (all-completions pattern completions predicate)) (progn (if (pos-visible-in-window-p (point-max) window) (set-window-start window (point-min)) (save-selected-window (select-window window) (scroll-up))) t)))) ;; Otherwise, do completion. (cond ((eq completion t)) ((null completion) (message "Can't find completion for \"%s\"" pattern) (ding)) ((not (string= pattern completion)) (delete-region (- (point) (length pattern)) (point)) (insert completion)) (t (message "Making completion list...") (let* ((list (all-completions pattern completions predicate)) ;; In case the transform needs to access it. (symbol-completion-predicate predicate) ;; Copy since list is side-effected by sorting. (copy (copy-sequence list))) (setq list (sort list 'string<)) (if (functionp symbol-completion-transform-function) (setq list (mapcar (funcall symbol-completion-transform-function) list))) (with-output-to-temp-buffer "*Completions*" (condition-case () (display-completion-list list pattern) ; Emacs 22 (error (display-completion-list list)))) ;; Record the list for determining whether to scroll ;; (above). (with-current-buffer "*Completions*" (set (make-local-variable 'displayed-completions) copy))) (message "Making completion list...%s" "done"))))))) (eval-when-compile (require 'hippie-exp)) ;;;###autoload (defun symbol-completion-try-complete (old) "Completion function for use with `hippie-expand'. Uses `symbol-completion-symbol-function' and `symbol-completion-completions-function'. It is intended to be used something like this in a major mode which provides symbol completion: (if (featurep 'hippie-exp) (set (make-local-variable 'hippie-expand-try-functions-list) (cons 'symbol-completion-try-complete hippie-expand-try-functions-list)))" (when (and symbol-completion-symbol-function symbol-completion-completions-function) (unless old (let ((symbol (funcall symbol-completion-symbol-function))) (he-init-string (- (point) (length symbol)) (point)) (if (not (he-string-member he-search-string he-tried-table)) (push he-search-string he-tried-table)) (setq he-expand-list (and symbol (funcall symbol-completion-completions-function symbol))))) (while (and he-expand-list (he-string-member (car he-expand-list) he-tried-table)) (pop he-expand-list)) (if he-expand-list (progn (he-substitute-string (pop he-expand-list)) t) (if old (he-reset-string)) nil))) ;;; Emacs Lisp symbol completion. (defun lisp-completion-symbol () "`symbol-completion-symbol-function' for Lisp." (let ((end (point)) (beg (with-syntax-table emacs-lisp-mode-syntax-table (save-excursion (backward-sexp 1) (while (= (char-syntax (following-char)) ?\') (forward-char 1)) (point))))) (buffer-substring-no-properties beg end))) (defun lisp-completion-predicate (beg end) "`symbol-completion-predicate-function' for Lisp." (save-excursion (goto-char beg) (if (not (eq (char-before) ?\()) (lambda (sym) ;why not just nil ? -sm ;To avoid interned symbols with ;no slots. -- fx (or (boundp sym) (fboundp sym) (symbol-plist sym))) ;; Looks like a funcall position. Let's double check. (if (condition-case nil (progn (up-list -2) (forward-char 1) (eq (char-after) ?\()) (error nil)) ;; If the first element of the parent list is an open ;; parenthesis we are probably not in a funcall position. ;; Maybe a `let' varlist or something. nil ;; Else, we assume that a function name is expected. 'fboundp)))) (defvar symbol-completion-predicate) (defun lisp-symbol-completion-transform () "`symbol-completion-transform-function' for Lisp." (lambda (elt) (if (and (not (eq 'fboundp symbol-completion-predicate)) (fboundp (intern elt))) (list elt " <f>") elt))) (provide 'sym-comp) ;; arch-tag: 6fcce616-f3c4-4751-94b4-710e83144124 ;;; sym-comp.el ends here