diff options
| author | Stefan Monnier | 2015-05-05 22:18:19 -0400 |
|---|---|---|
| committer | Stefan Monnier | 2015-05-05 22:18:19 -0400 |
| commit | a7d630eb4895a392bcc0d9986d1ca5382a4f7b96 (patch) | |
| tree | a7dba5dd168029652d5640cac86e5c97444c0563 /lisp/progmodes | |
| parent | 0ed044dc1b524370f02f531b3b6fcc1ef45c395d (diff) | |
| download | emacs-a7d630eb4895a392bcc0d9986d1ca5382a4f7b96.tar.gz emacs-a7d630eb4895a392bcc0d9986d1ca5382a4f7b96.zip | |
* lisp/cedet/semantic/grammar.el: Fix compiler warnings (bug#20505)
(semantic-grammar--template-expand): New function.
(semantic-grammar-header, semantic-grammar-footer): Use it.
(semantic-grammar--lex-block-specs): Remove unused var `block-spec'.
(semantic-grammar-file-regexp): Refine regexp.
(semantic-grammar-eldoc-get-macro-docstring):
Use elisp-get-fnsym-args-string when available.
(semantic-idle-summary-current-symbol-info): Use new elisp-* names
instead of the old eldoc-* names.
* lisp/emacs-lisp/eldoc.el (eldoc-docstring-format-sym-doc): Move back
from elisp-mode.el. Tweak calling convention.
* lisp/progmodes/elisp-mode.el (package-user-dir): Declare.
(elisp-get-fnsym-args-string): Add `prefix' argument. Rename from
elisp--get-fnsym-args-string.
(elisp--highlight-function-argument): Add `prefix' arg.
(elisp-get-var-docstring): Rename from elisp--get-var-docstring.
(elisp--docstring-format-sym-doc): Move back to eldoc.el.
Diffstat (limited to 'lisp/progmodes')
| -rw-r--r-- | lisp/progmodes/elisp-mode.el | 75 |
1 files changed, 26 insertions, 49 deletions
diff --git a/lisp/progmodes/elisp-mode.el b/lisp/progmodes/elisp-mode.el index dac807e4334..7bc7798be03 100644 --- a/lisp/progmodes/elisp-mode.el +++ b/lisp/progmodes/elisp-mode.el | |||
| @@ -650,11 +650,14 @@ It can be quoted, or be inside a quoted form." | |||
| 650 | lst)))) | 650 | lst)))) |
| 651 | lst))) | 651 | lst))) |
| 652 | 652 | ||
| 653 | (defvar package-user-dir) | ||
| 654 | |||
| 653 | (defun elisp--xref-find-references (symbol) | 655 | (defun elisp--xref-find-references (symbol) |
| 654 | (let* ((dirs (sort | 656 | (let* ((dirs (sort |
| 655 | (mapcar | 657 | (mapcar |
| 656 | (lambda (dir) | 658 | (lambda (dir) |
| 657 | (file-name-as-directory (expand-file-name dir))) | 659 | (file-name-as-directory (expand-file-name dir))) |
| 660 | ;; FIXME: Why add package-user-dir? | ||
| 658 | (cons package-user-dir load-path)) | 661 | (cons package-user-dir load-path)) |
| 659 | #'string<)) | 662 | #'string<)) |
| 660 | (ref dirs)) | 663 | (ref dirs)) |
| @@ -1174,13 +1177,13 @@ which see." | |||
| 1174 | (cond ((null current-fnsym) | 1177 | (cond ((null current-fnsym) |
| 1175 | nil) | 1178 | nil) |
| 1176 | ((eq current-symbol (car current-fnsym)) | 1179 | ((eq current-symbol (car current-fnsym)) |
| 1177 | (or (apply #'elisp--get-fnsym-args-string current-fnsym) | 1180 | (or (apply #'elisp-get-fnsym-args-string current-fnsym) |
| 1178 | (elisp--get-var-docstring current-symbol))) | 1181 | (elisp-get-var-docstring current-symbol))) |
| 1179 | (t | 1182 | (t |
| 1180 | (or (elisp--get-var-docstring current-symbol) | 1183 | (or (elisp-get-var-docstring current-symbol) |
| 1181 | (apply #'elisp--get-fnsym-args-string current-fnsym)))))) | 1184 | (apply #'elisp-get-fnsym-args-string current-fnsym)))))) |
| 1182 | 1185 | ||
| 1183 | (defun elisp--get-fnsym-args-string (sym &optional index) | 1186 | (defun elisp-get-fnsym-args-string (sym &optional index prefix) |
| 1184 | "Return a string containing the parameter list of the function SYM. | 1187 | "Return a string containing the parameter list of the function SYM. |
| 1185 | If SYM is a subr and no arglist is obtainable from the docstring | 1188 | If SYM is a subr and no arglist is obtainable from the docstring |
| 1186 | or elsewhere, return a 1-line docstring." | 1189 | or elsewhere, return a 1-line docstring." |
| @@ -1204,16 +1207,22 @@ or elsewhere, return a 1-line docstring." | |||
| 1204 | (car doc)) | 1207 | (car doc)) |
| 1205 | (t (help-function-arglist sym))))) | 1208 | (t (help-function-arglist sym))))) |
| 1206 | ;; Stringify, and store before highlighting, downcasing, etc. | 1209 | ;; Stringify, and store before highlighting, downcasing, etc. |
| 1207 | ;; FIXME should truncate before storing. | 1210 | (elisp--last-data-store sym (elisp-function-argstring args) |
| 1208 | (elisp--last-data-store sym (elisp--function-argstring args) | ||
| 1209 | 'function)))))) | 1211 | 'function)))))) |
| 1210 | ;; Highlight, truncate. | 1212 | ;; Highlight, truncate. |
| 1211 | (if argstring | 1213 | (if argstring |
| 1212 | (elisp--highlight-function-argument sym argstring index)))) | 1214 | (elisp--highlight-function-argument |
| 1213 | 1215 | sym argstring index | |
| 1214 | (defun elisp--highlight-function-argument (sym args index) | 1216 | (or prefix |
| 1217 | (concat (propertize (symbol-name sym) 'face | ||
| 1218 | (if (functionp sym) | ||
| 1219 | 'font-lock-function-name-face | ||
| 1220 | 'font-lock-keyword-face)) | ||
| 1221 | ": ")))))) | ||
| 1222 | |||
| 1223 | (defun elisp--highlight-function-argument (sym args index prefix) | ||
| 1215 | "Highlight argument INDEX in ARGS list for function SYM. | 1224 | "Highlight argument INDEX in ARGS list for function SYM. |
| 1216 | In the absence of INDEX, just call `elisp--docstring-format-sym-doc'." | 1225 | In the absence of INDEX, just call `eldoc-docstring-format-sym-doc'." |
| 1217 | ;; FIXME: This should probably work on the list representation of `args' | 1226 | ;; FIXME: This should probably work on the list representation of `args' |
| 1218 | ;; rather than its string representation. | 1227 | ;; rather than its string representation. |
| 1219 | ;; FIXME: This function is much too long, we need to split it up! | 1228 | ;; FIXME: This function is much too long, we need to split it up! |
| @@ -1298,9 +1307,9 @@ In the absence of INDEX, just call `elisp--docstring-format-sym-doc'." | |||
| 1298 | ((string= argument "&allow-other-keys")) ; Skip. | 1307 | ((string= argument "&allow-other-keys")) ; Skip. |
| 1299 | ;; Back to index 0 in ARG1 ARG2 ARG2 ARG3 etc... | 1308 | ;; Back to index 0 in ARG1 ARG2 ARG2 ARG3 etc... |
| 1300 | ;; like in `setq'. | 1309 | ;; like in `setq'. |
| 1301 | ((or (and (string-match-p "\\.\\.\\.$" argument) | 1310 | ((or (and (string-match-p "\\.\\.\\.\\'" argument) |
| 1302 | (string= argument (car (last args-lst)))) | 1311 | (string= argument (car (last args-lst)))) |
| 1303 | (and (string-match-p "\\.\\.\\.$" | 1312 | (and (string-match-p "\\.\\.\\.\\'" |
| 1304 | (substring args 1 (1- (length args)))) | 1313 | (substring args 1 (1- (length args)))) |
| 1305 | (= (length (remove "..." args-lst)) 2) | 1314 | (= (length (remove "..." args-lst)) 2) |
| 1306 | (> index 1) (eq (logand index 1) 1))) | 1315 | (> index 1) (eq (logand index 1) 1))) |
| @@ -1315,14 +1324,12 @@ In the absence of INDEX, just call `elisp--docstring-format-sym-doc'." | |||
| 1315 | (when start | 1324 | (when start |
| 1316 | (setq doc (copy-sequence args)) | 1325 | (setq doc (copy-sequence args)) |
| 1317 | (add-text-properties start end (list 'face argument-face) doc)) | 1326 | (add-text-properties start end (list 'face argument-face) doc)) |
| 1318 | (setq doc (elisp--docstring-format-sym-doc | 1327 | (setq doc (eldoc-docstring-format-sym-doc prefix doc)) |
| 1319 | sym doc (if (functionp sym) 'font-lock-function-name-face | ||
| 1320 | 'font-lock-keyword-face))) | ||
| 1321 | doc))) | 1328 | doc))) |
| 1322 | 1329 | ||
| 1323 | ;; Return a string containing a brief (one-line) documentation string for | 1330 | ;; Return a string containing a brief (one-line) documentation string for |
| 1324 | ;; the variable. | 1331 | ;; the variable. |
| 1325 | (defun elisp--get-var-docstring (sym) | 1332 | (defun elisp-get-var-docstring (sym) |
| 1326 | (cond ((not sym) nil) | 1333 | (cond ((not sym) nil) |
| 1327 | ((and (eq sym (aref elisp--eldoc-last-data 0)) | 1334 | ((and (eq sym (aref elisp--eldoc-last-data 0)) |
| 1328 | (eq 'variable (aref elisp--eldoc-last-data 2))) | 1335 | (eq 'variable (aref elisp--eldoc-last-data 2))) |
| @@ -1330,7 +1337,7 @@ In the absence of INDEX, just call `elisp--docstring-format-sym-doc'." | |||
| 1330 | (t | 1337 | (t |
| 1331 | (let ((doc (documentation-property sym 'variable-documentation t))) | 1338 | (let ((doc (documentation-property sym 'variable-documentation t))) |
| 1332 | (when doc | 1339 | (when doc |
| 1333 | (let ((doc (elisp--docstring-format-sym-doc | 1340 | (let ((doc (eldoc-docstring-format-sym-doc |
| 1334 | sym (elisp--docstring-first-line doc) | 1341 | sym (elisp--docstring-first-line doc) |
| 1335 | 'font-lock-variable-name-face))) | 1342 | 'font-lock-variable-name-face))) |
| 1336 | (elisp--last-data-store sym doc 'variable))))))) | 1343 | (elisp--last-data-store sym doc 'variable))))))) |
| @@ -1354,36 +1361,6 @@ In the absence of INDEX, just call `elisp--docstring-format-sym-doc'." | |||
| 1354 | (substring doc start (match-beginning 0))) | 1361 | (substring doc start (match-beginning 0))) |
| 1355 | ((zerop start) doc) | 1362 | ((zerop start) doc) |
| 1356 | (t (substring doc start)))))))) | 1363 | (t (substring doc start)))))))) |
| 1357 | |||
| 1358 | (defvar eldoc-echo-area-use-multiline-p) | ||
| 1359 | |||
| 1360 | ;; If the entire line cannot fit in the echo area, the symbol name may be | ||
| 1361 | ;; truncated or eliminated entirely from the output to make room for the | ||
| 1362 | ;; description. | ||
| 1363 | (defun elisp--docstring-format-sym-doc (sym doc face) | ||
| 1364 | (save-match-data | ||
| 1365 | (let* ((name (symbol-name sym)) | ||
| 1366 | (ea-multi eldoc-echo-area-use-multiline-p) | ||
| 1367 | ;; Subtract 1 from window width since emacs will not write | ||
| 1368 | ;; any chars to the last column, or in later versions, will | ||
| 1369 | ;; cause a wraparound and resize of the echo area. | ||
| 1370 | (ea-width (1- (window-width (minibuffer-window)))) | ||
| 1371 | (strip (- (+ (length name) (length ": ") (length doc)) ea-width))) | ||
| 1372 | (cond ((or (<= strip 0) | ||
| 1373 | (eq ea-multi t) | ||
| 1374 | (and ea-multi (> (length doc) ea-width))) | ||
| 1375 | (format "%s: %s" (propertize name 'face face) doc)) | ||
| 1376 | ((> (length doc) ea-width) | ||
| 1377 | (substring (format "%s" doc) 0 ea-width)) | ||
| 1378 | ((>= strip (length name)) | ||
| 1379 | (format "%s" doc)) | ||
| 1380 | (t | ||
| 1381 | ;; Show the end of the partial symbol name, rather | ||
| 1382 | ;; than the beginning, since the former is more likely | ||
| 1383 | ;; to be unique given package namespace conventions. | ||
| 1384 | (setq name (substring name strip)) | ||
| 1385 | (format "%s: %s" (propertize name 'face face) doc)))))) | ||
| 1386 | |||
| 1387 | 1364 | ||
| 1388 | ;; Return a list of current function name and argument index. | 1365 | ;; Return a list of current function name and argument index. |
| 1389 | (defun elisp--fnsym-in-current-sexp () | 1366 | (defun elisp--fnsym-in-current-sexp () |
| @@ -1428,7 +1405,7 @@ In the absence of INDEX, just call `elisp--docstring-format-sym-doc'." | |||
| 1428 | (memq (char-syntax c) '(?w ?_)) | 1405 | (memq (char-syntax c) '(?w ?_)) |
| 1429 | (intern-soft (current-word))))) | 1406 | (intern-soft (current-word))))) |
| 1430 | 1407 | ||
| 1431 | (defun elisp--function-argstring (arglist) | 1408 | (defun elisp-function-argstring (arglist) |
| 1432 | "Return ARGLIST as a string enclosed by (). | 1409 | "Return ARGLIST as a string enclosed by (). |
| 1433 | ARGLIST is either a string, or a list of strings or symbols." | 1410 | ARGLIST is either a string, or a list of strings or symbols." |
| 1434 | (let ((str (cond ((stringp arglist) arglist) | 1411 | (let ((str (cond ((stringp arglist) arglist) |