Mercurial > emacs
annotate lisp/linum.el @ 110523:a5ad4f188e19
Synch Semantic to CEDET 1.0.
Move CEDET ChangeLog entries to new file lisp/cedet/ChangeLog.
* semantic.el (semantic-version): Update to 2.0.
(semantic-mode-map): Add "," and "m" bindings.
(navigate-menu): Update.
* semantic/symref.el (semantic-symref-calculate-rootdir):
New function.
(semantic-symref-detect-symref-tool): Use it.
* semantic/symref/grep.el (semantic-symref-grep-shell): New var.
(semantic-symref-perform-search): Use it. Calculate root dir with
semantic-symref-calculate-rootdir.
(semantic-symref-derive-find-filepatterns): Improve error message.
* semantic/symref/list.el
(semantic-symref-results-mode-map): New bindings.
(semantic-symref-auto-expand-results): New option.
(semantic-symref-results-dump): Obey auto-expand.
(semantic-symref-list-expand-all, semantic-symref-regexp)
(semantic-symref-list-contract-all)
(semantic-symref-list-map-open-hits)
(semantic-symref-list-update-open-hits)
(semantic-symref-list-create-macro-on-open-hit)
(semantic-symref-list-call-macro-on-open-hits): New functions.
(semantic-symref-list-menu-entries)
(semantic-symref-list-menu): New vars.
(semantic-symref-list-map-open-hits): Move cursor to beginning of
match before calling the mapped function.
* semantic/doc.el
(semantic-documentation-comment-preceeding-tag): Do nothing if the
mode doesn't provide comment-start-skip.
* semantic/scope.el
(semantic-analyze-scope-nested-tags-default): Strip duplicates.
(semantic-analyze-scoped-inherited-tag-map): Take the tag we are
looking for as part of the scoped tags list.
* semantic/html.el (semantic-default-html-setup): Add
senator-step-at-tag-classes.
* semantic/decorate/include.el
(semantic-decoration-on-unknown-includes): Change light bgcolor.
(semantic-decoration-on-includes-highlight-default): Check that
the include tag has a postion.
* semantic/complete.el (semantic-collector-local-members):
(semantic-complete-read-tag-local-members)
(semantic-complete-jump-local-members): New class and functions.
(semantic-complete-self-insert): Save excursion before completing.
* semantic/analyze/complete.el
(semantic-analyze-possible-completions-default): If no completions
are found, return the raw by-name-only completion list. Add FLAGS
arguments. Add support for 'no-tc (type constraint) and
'no-unique, or no stripping duplicates.
(semantic-analyze-possible-completions-default): Add FLAGS arg.
* semantic/util-modes.el
(semantic-stickyfunc-show-only-functions-p): New option.
(semantic-stickyfunc-fetch-stickyline): Don't show stickytext for
the very first line in a buffer.
* semantic/util.el (semantic-hack-search)
(semantic-recursive-find-nonterminal-by-name)
(semantic-current-tag-interactive): Deleted.
(semantic-describe-buffer): Fix expand-nonterminal. Add
lex-syntax-mods, type relation separator char, and command
separation char.
(semantic-sanity-check): Only message if called interactively.
* semantic/tag.el (semantic-tag-deep-copy-one-tag): Copy the
:filename property and the tag position.
* semantic/lex-spp.el (semantic-lex-spp-lex-text-string):
Add recursion limit.
* semantic/imenu.el (semantic-imenu-bucketize-type-members):
Make this buffer local, not the obsoleted variable.
* semantic/idle.el: Add breadcrumbs support.
(semantic-idle-summary-current-symbol-info-default)
(semantic-idle-tag-highlight)
(semantic-idle-completion-list-default): Use
semanticdb-without-unloaded-file-searches for speed, and to
conform to the controls that specify if the idle timer is supposed
to be parsing unparsed includes.
(semantic-idle-symbol-highlight-face)
(semantic-idle-symbol-maybe-highlight): Rename from *-summary-*.
Callers changed.
(semantic-idle-work-parse-neighboring-files-flag): Default to nil.
(semantic-idle-work-update-headers-flag): New var.
(semantic-idle-work-for-one-buffer): Use it.
(semantic-idle-local-symbol-highlight): Rename from
semantic-idle-tag-highlight.
(semantic-idle-truncate-long-summaries): New option.
* semantic/ia.el (semantic-ia-cache)
(semantic-ia-get-completions): Deleted. Callers changed.
(semantic-ia-show-variants): New command.
(semantic-ia-show-doc): If doc is empty, don't make a temp buffer.
(semantic-ia-show-summary): If there isn't anything to show, say so.
* semantic/grammar.el (semantic-grammar-create-package):
Save the buffer even in batch mode.
* semantic/fw.el
(semanticdb-without-unloaded-file-searches): New macro.
* semantic/dep.el (semantic-dependency-find-file-on-path):
Fix case dereferencing ede-object when it is a list.
* semantic/db-typecache.el (semanticdb-expand-nested-tag)
(semanticdb-typecache-faux-namespace): New functions.
(semanticdb-typecache-file-tags)
(semanticdb-typecache-merge-streams): Use them.
(semanticdb-typecache-file-tags): When deriving tags from a file,
give the mode a chance to monkey with the tag copy.
(semanticdb-typecache-find-default): Wrap find in save-excursion.
(semanticdb-typecache-find-by-name-helper): Merge found names down.
* semantic/db-global.el
(semanticdb-enable-gnu-global-in-buffer): Don't show messages if
GNU Global is not available and we don't want to throw an error.
* semantic/db-find.el (semanticdb-find-result-nth-in-buffer):
When trying to normalize the tag to a buffer, don't error if
set-buffer method doesn't exist.
* semantic/db-file.el (semanticdb-save-db): Simplify msg.
* semantic/db.el (semanticdb-refresh-table): If forcing a
refresh on a file not in a buffer, use semantic-find-file-noselect
and delete the buffer after use.
(semanticdb-current-database-list): When calculating root via
hooks, force it through true-filename and skip the list of
possible roots.
* semantic/ctxt.el (semantic-ctxt-imported-packages): New.
* semantic/analyze/debug.el
(semantic-analyzer-debug-insert-tag): Reset standard output to
current buffer.
(semantic-analyzer-debug-global-symbol)
(semantic-analyzer-debug-missing-innertype): Change "prefix" to
"symbol" in messages.
* semantic/analyze/refs.el: (semantic-analyze-refs-impl)
(semantic-analyze-refs-proto): When calculating value, make sure
the found tag is 'similar' to the originating tag.
(semantic--analyze-refs-find-tags-with-parent): Attempt to
identify matches via imported symbols of parents.
(semantic--analyze-refs-full-lookup-with-parents): Do a deep
search during the brute search.
* semantic/analyze.el
(semantic-analyze-find-tag-sequence-default): Be robust to
calculated scopes being nil.
* semantic/bovine/c.el (semantic-c-describe-environment): Add
project macro symbol array.
(semantic-c-parse-lexical-token): Add recursion limit.
(semantic-ctxt-imported-packages, semanticdb-expand-nested-tag):
New overrides.
(semantic-expand-c-tag-namelist): Split a full type from a typedef
out to its own tag.
(semantic-expand-c-tag-namelist): Do not split out a typedef'd
inline type if it is an anonymous type.
(semantic-c-reconstitute-token): Use the optional initializers as
a clue that some function is probably a constructor. When
defining the type of these constructors, split the parent name,
and use only the class part, if applicable.
* semantic/bovine/c-by.el:
* semantic/wisent/python-wy.el: Regenerate.
author | Chong Yidong <cyd@stupidchicken.com> |
---|---|
date | Sat, 18 Sep 2010 22:49:54 -0400 |
parents | 1d1d5d9bd884 |
children | a3e1f7134e6e 376148b31b5e |
rev | line source |
---|---|
97899 | 1 ;;; linum.el --- display line numbers in the left margin |
2 | |
106815 | 3 ;; Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc. |
97899 | 4 |
5 ;; Author: Markus Triska <markus.triska@gmx.at> | |
6 ;; Maintainer: FSF | |
7 ;; Keywords: convenience | |
8 | |
9 ;; This file is part of GNU Emacs. | |
10 | |
11 ;; GNU Emacs is free software: you can redistribute it and/or modify | |
12 ;; it under the terms of the GNU General Public License as published by | |
13 ;; the Free Software Foundation, either version 3 of the License, or | |
14 ;; (at your option) any later version. | |
15 | |
16 ;; GNU Emacs is distributed in the hope that it will be useful, | |
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 ;; GNU General Public License for more details. | |
20 | |
21 ;; You should have received a copy of the GNU General Public License | |
22 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. | |
23 | |
24 ;;; Commentary: | |
25 | |
26 ;; Display line numbers for the current buffer. | |
27 ;; | |
28 ;; Toggle display of line numbers with M-x linum-mode. To enable | |
29 ;; line numbering in all buffers, use M-x global-linum-mode. | |
30 | |
31 ;;; Code: | |
32 | |
33 (defconst linum-version "0.9x") | |
34 | |
35 (defvar linum-overlays nil "Overlays used in this buffer.") | |
36 (defvar linum-available nil "Overlays available for reuse.") | |
37 (defvar linum-before-numbering-hook nil | |
38 "Functions run in each buffer before line numbering starts.") | |
39 | |
40 (mapc #'make-variable-buffer-local '(linum-overlays linum-available)) | |
41 | |
42 (defgroup linum nil | |
43 "Show line numbers in the left margin." | |
44 :group 'convenience) | |
45 | |
46 ;;;###autoload | |
47 (defcustom linum-format 'dynamic | |
48 "Format used to display line numbers. | |
49 Either a format string like \"%7d\", `dynamic' to adapt the width | |
50 as needed, or a function that is called with a line number as its | |
51 argument and should evaluate to a string to be shown on that line. | |
52 See also `linum-before-numbering-hook'." | |
53 :group 'linum | |
54 :type 'sexp) | |
55 | |
56 (defface linum | |
57 '((t :inherit (shadow default))) | |
58 "Face for displaying line numbers in the display margin." | |
59 :group 'linum) | |
60 | |
61 (defcustom linum-eager t | |
62 "Whether line numbers should be updated after each command. | |
63 The conservative setting `nil' might miss some buffer changes, | |
64 and you have to scroll or press \\[recenter-top-bottom] to update the numbers." | |
65 :group 'linum | |
66 :type 'boolean) | |
67 | |
68 (defcustom linum-delay nil | |
69 "Delay updates to give Emacs a chance for other changes." | |
70 :group 'linum | |
71 :type 'boolean) | |
72 | |
73 ;;;###autoload | |
74 (define-minor-mode linum-mode | |
75 "Toggle display of line numbers in the left margin." | |
76 :lighter "" ; for desktop.el | |
77 (if linum-mode | |
78 (progn | |
79 (if linum-eager | |
80 (add-hook 'post-command-hook (if linum-delay | |
81 'linum-schedule | |
82 'linum-update-current) nil t) | |
83 (add-hook 'after-change-functions 'linum-after-change nil t)) | |
84 (add-hook 'window-scroll-functions 'linum-after-scroll nil t) | |
104365
fe22bf79af7f
(linum-mode): window-size-change-functions is redundant.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
101274
diff
changeset
|
85 ;; Using both window-size-change-functions and |
fe22bf79af7f
(linum-mode): window-size-change-functions is redundant.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
101274
diff
changeset
|
86 ;; window-configuration-change-hook seems redundant. --Stef |
fe22bf79af7f
(linum-mode): window-size-change-functions is redundant.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
101274
diff
changeset
|
87 ;; (add-hook 'window-size-change-functions 'linum-after-size nil t) |
97899 | 88 (add-hook 'change-major-mode-hook 'linum-delete-overlays nil t) |
89 (add-hook 'window-configuration-change-hook | |
104365
fe22bf79af7f
(linum-mode): window-size-change-functions is redundant.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
101274
diff
changeset
|
90 ;; FIXME: If the buffer is shown in N windows, this |
fe22bf79af7f
(linum-mode): window-size-change-functions is redundant.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
101274
diff
changeset
|
91 ;; will be called N times rather than once. We should use |
fe22bf79af7f
(linum-mode): window-size-change-functions is redundant.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
101274
diff
changeset
|
92 ;; something like linum-update-window instead. |
fe22bf79af7f
(linum-mode): window-size-change-functions is redundant.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
101274
diff
changeset
|
93 'linum-update-current nil t) |
97899 | 94 (linum-update-current)) |
95 (remove-hook 'post-command-hook 'linum-update-current t) | |
96 (remove-hook 'post-command-hook 'linum-schedule t) | |
104365
fe22bf79af7f
(linum-mode): window-size-change-functions is redundant.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
101274
diff
changeset
|
97 ;; (remove-hook 'window-size-change-functions 'linum-after-size t) |
97899 | 98 (remove-hook 'window-scroll-functions 'linum-after-scroll t) |
99 (remove-hook 'after-change-functions 'linum-after-change t) | |
104365
fe22bf79af7f
(linum-mode): window-size-change-functions is redundant.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
101274
diff
changeset
|
100 (remove-hook 'window-configuration-change-hook 'linum-update-current t) |
97899 | 101 (remove-hook 'change-major-mode-hook 'linum-delete-overlays t) |
102 (linum-delete-overlays))) | |
103 | |
104 ;;;###autoload | |
105 (define-globalized-minor-mode global-linum-mode linum-mode linum-on) | |
106 | |
107 (defun linum-on () | |
108 (unless (minibufferp) | |
109 (linum-mode 1))) | |
110 | |
111 (defun linum-delete-overlays () | |
112 "Delete all overlays displaying line numbers for this buffer." | |
113 (mapc #'delete-overlay linum-overlays) | |
114 (setq linum-overlays nil) | |
115 (dolist (w (get-buffer-window-list (current-buffer) nil t)) | |
105135
708c5f10a0be
* linum.el (linum-delete-overlays, linum-update-window):
Juanma Barranquero <lekktu@gmail.com>
parents:
104365
diff
changeset
|
116 (set-window-margins w 0 (cdr (window-margins w))))) |
97899 | 117 |
118 (defun linum-update-current () | |
119 "Update line numbers for the current buffer." | |
120 (linum-update (current-buffer))) | |
121 | |
122 (defun linum-update (buffer) | |
123 "Update line numbers for all windows displaying BUFFER." | |
124 (with-current-buffer buffer | |
125 (when linum-mode | |
126 (setq linum-available linum-overlays) | |
127 (setq linum-overlays nil) | |
128 (save-excursion | |
129 (mapc #'linum-update-window | |
130 (get-buffer-window-list buffer nil 'visible))) | |
131 (mapc #'delete-overlay linum-available) | |
132 (setq linum-available nil)))) | |
133 | |
134 (defun linum-update-window (win) | |
135 "Update line numbers for the portion visible in window WIN." | |
136 (goto-char (window-start win)) | |
137 (let ((line (line-number-at-pos)) | |
138 (limit (window-end win t)) | |
139 (fmt (cond ((stringp linum-format) linum-format) | |
140 ((eq linum-format 'dynamic) | |
141 (let ((w (length (number-to-string | |
142 (count-lines (point-min) (point-max)))))) | |
143 (concat "%" (number-to-string w) "d"))))) | |
144 (width 0)) | |
145 (run-hooks 'linum-before-numbering-hook) | |
146 ;; Create an overlay (or reuse an existing one) for each | |
147 ;; line visible in this window, if necessary. | |
148 (while (and (not (eobp)) (<= (point) limit)) | |
149 (let* ((str (if fmt | |
150 (propertize (format fmt line) 'face 'linum) | |
151 (funcall linum-format line))) | |
152 (visited (catch 'visited | |
153 (dolist (o (overlays-in (point) (point))) | |
101274
4bcf5c96d5ee
* linum.el (linum-update-window): Use `delq' instead of `delete';
Juanma Barranquero <lekktu@gmail.com>
parents:
100908
diff
changeset
|
154 (when (equal-including-properties |
4bcf5c96d5ee
* linum.el (linum-update-window): Use `delq' instead of `delete';
Juanma Barranquero <lekktu@gmail.com>
parents:
100908
diff
changeset
|
155 (overlay-get o 'linum-str) str) |
97899 | 156 (unless (memq o linum-overlays) |
157 (push o linum-overlays)) | |
101274
4bcf5c96d5ee
* linum.el (linum-update-window): Use `delq' instead of `delete';
Juanma Barranquero <lekktu@gmail.com>
parents:
100908
diff
changeset
|
158 (setq linum-available (delq o linum-available)) |
97899 | 159 (throw 'visited t)))))) |
160 (setq width (max width (length str))) | |
161 (unless visited | |
162 (let ((ov (if (null linum-available) | |
163 (make-overlay (point) (point)) | |
164 (move-overlay (pop linum-available) (point) (point))))) | |
165 (push ov linum-overlays) | |
166 (overlay-put ov 'before-string | |
167 (propertize " " 'display `((margin left-margin) ,str))) | |
168 (overlay-put ov 'linum-str str)))) | |
106225
5418676a97db
(linum-update-window): Ignore intangible (bug#4996).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105135
diff
changeset
|
169 ;; Text may contain those nasty intangible properties, but that |
5418676a97db
(linum-update-window): Ignore intangible (bug#4996).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105135
diff
changeset
|
170 ;; shouldn't prevent us from counting those lines. |
5418676a97db
(linum-update-window): Ignore intangible (bug#4996).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105135
diff
changeset
|
171 (let ((inhibit-point-motion-hooks t)) |
5418676a97db
(linum-update-window): Ignore intangible (bug#4996).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105135
diff
changeset
|
172 (forward-line)) |
97899 | 173 (setq line (1+ line))) |
105135
708c5f10a0be
* linum.el (linum-delete-overlays, linum-update-window):
Juanma Barranquero <lekktu@gmail.com>
parents:
104365
diff
changeset
|
174 (set-window-margins win width (cdr (window-margins win))))) |
97899 | 175 |
176 (defun linum-after-change (beg end len) | |
177 ;; update overlays on deletions, and after newlines are inserted | |
178 (when (or (= beg end) | |
179 (= end (point-max)) | |
180 (string-match-p "\n" (buffer-substring-no-properties beg end))) | |
181 (linum-update-current))) | |
182 | |
183 (defun linum-after-scroll (win start) | |
184 (linum-update (window-buffer win))) | |
185 | |
104365
fe22bf79af7f
(linum-mode): window-size-change-functions is redundant.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
101274
diff
changeset
|
186 ;; (defun linum-after-size (frame) |
fe22bf79af7f
(linum-mode): window-size-change-functions is redundant.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
101274
diff
changeset
|
187 ;; (linum-after-config)) |
97899 | 188 |
189 (defun linum-schedule () | |
190 ;; schedule an update; the delay gives Emacs a chance for display changes | |
191 (run-with-idle-timer 0 nil #'linum-update-current)) | |
192 | |
104365
fe22bf79af7f
(linum-mode): window-size-change-functions is redundant.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
101274
diff
changeset
|
193 ;; (defun linum-after-config () |
fe22bf79af7f
(linum-mode): window-size-change-functions is redundant.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
101274
diff
changeset
|
194 ;; (walk-windows (lambda (w) (linum-update (window-buffer w))) nil 'visible)) |
97899 | 195 |
196 (defun linum-unload-function () | |
197 "Unload the Linum library." | |
198 (global-linum-mode -1) | |
199 ;; continue standard unloading | |
200 nil) | |
201 | |
202 (provide 'linum) | |
203 | |
204 ;; arch-tag: dea45631-ed3c-4867-8b49-1c41c80aec6a | |
205 ;;; linum.el ends here |