diff options
| author | Stefan Monnier | 2019-03-10 03:54:46 -0400 |
|---|---|---|
| committer | Stefan Monnier | 2019-03-10 03:54:46 -0400 |
| commit | e70a65d403a67c25b17229bce8f173f0ab1b2f74 (patch) | |
| tree | 0317b68c7e19d14c8bf5df92671ed70b427d0de4 | |
| parent | affd2a0cee901404251ea1d2ef01bfb618f5213a (diff) | |
| download | emacs-e70a65d403a67c25b17229bce8f173f0ab1b2f74.tar.gz emacs-e70a65d403a67c25b17229bce8f173f0ab1b2f74.zip | |
* lisp/speedbar.el: Minor tweaks
(speedbar-directory-buttons-follow): Use file-name-as-directory.
(speedbar-ignored-directory-expressions)
(speedbar-supported-extension-expressions): Use `sym` in the setter.
(speedbar-frame-mode): Use with-current-buffer.
(speedbar-item-info-tag-helper): Use 'cond'.
(speedbar-highlight-one-tag-line): Don't use position beyond EOB.
| -rw-r--r-- | lisp/speedbar.el | 127 |
1 files changed, 63 insertions, 64 deletions
diff --git a/lisp/speedbar.el b/lisp/speedbar.el index a7fd564e948..399ef4557b8 100644 --- a/lisp/speedbar.el +++ b/lisp/speedbar.el | |||
| @@ -647,9 +647,9 @@ speedbar is loaded. You may place anything you like in this list | |||
| 647 | before speedbar has been loaded." | 647 | before speedbar has been loaded." |
| 648 | :group 'speedbar | 648 | :group 'speedbar |
| 649 | :type '(repeat (regexp :tag "Directory Regexp")) | 649 | :type '(repeat (regexp :tag "Directory Regexp")) |
| 650 | :set (lambda (_sym val) | 650 | :set (lambda (sym val) |
| 651 | (setq speedbar-ignored-directory-expressions val | 651 | (set sym val) |
| 652 | speedbar-ignored-directory-regexp | 652 | (setq speedbar-ignored-directory-regexp |
| 653 | (speedbar-extension-list-to-regex val)))) | 653 | (speedbar-extension-list-to-regex val)))) |
| 654 | 654 | ||
| 655 | (defcustom speedbar-directory-unshown-regexp "^\\(\\..*\\)\\'" | 655 | (defcustom speedbar-directory-unshown-regexp "^\\(\\..*\\)\\'" |
| @@ -701,9 +701,9 @@ need to also modify `completion-ignored-extension' which will also help | |||
| 701 | file completion." | 701 | file completion." |
| 702 | :group 'speedbar | 702 | :group 'speedbar |
| 703 | :type '(repeat (regexp :tag "Extension Regexp")) | 703 | :type '(repeat (regexp :tag "Extension Regexp")) |
| 704 | :set (lambda (_sym val) | 704 | :set (lambda (sym val) |
| 705 | (set 'speedbar-supported-extension-expressions val) | 705 | (set sym val) |
| 706 | (set 'speedbar-file-regexp (speedbar-extension-list-to-regex val)))) | 706 | (setq speedbar-file-regexp (speedbar-extension-list-to-regex val)))) |
| 707 | 707 | ||
| 708 | (setq speedbar-file-regexp | 708 | (setq speedbar-file-regexp |
| 709 | (speedbar-extension-list-to-regex speedbar-supported-extension-expressions)) | 709 | (speedbar-extension-list-to-regex speedbar-supported-extension-expressions)) |
| @@ -972,9 +972,8 @@ supported at a time. | |||
| 972 | (interactive "P") | 972 | (interactive "P") |
| 973 | ;; Get the buffer to play with | 973 | ;; Get the buffer to play with |
| 974 | (if (not (buffer-live-p speedbar-buffer)) | 974 | (if (not (buffer-live-p speedbar-buffer)) |
| 975 | (save-excursion | 975 | (with-current-buffer |
| 976 | (setq speedbar-buffer (get-buffer-create " SPEEDBAR")) | 976 | (setq speedbar-buffer (get-buffer-create " SPEEDBAR")) |
| 977 | (set-buffer speedbar-buffer) | ||
| 978 | (speedbar-mode))) | 977 | (speedbar-mode))) |
| 979 | ;; Do the frame thing | 978 | ;; Do the frame thing |
| 980 | (dframe-frame-mode arg | 979 | (dframe-frame-mode arg |
| @@ -1476,57 +1475,59 @@ instead of reading it from the speedbar buffer." | |||
| 1476 | Return nil if not applicable." | 1475 | Return nil if not applicable." |
| 1477 | (save-excursion | 1476 | (save-excursion |
| 1478 | (beginning-of-line) | 1477 | (beginning-of-line) |
| 1479 | (if (re-search-forward " [-+=]?> \\([^\n]+\\)" (line-end-position) t) | 1478 | (cond |
| 1480 | (let* ((tag (match-string 1)) | 1479 | ((re-search-forward " [-+=]?> \\([^\n]+\\)" (line-end-position) t) |
| 1481 | (attr (speedbar-line-token)) | 1480 | (let* ((tag (match-string 1)) |
| 1482 | (item nil) | 1481 | (attr (speedbar-line-token)) |
| 1483 | (semantic-tagged (if (fboundp 'semantic-tag-p) | 1482 | (item nil) |
| 1484 | (semantic-tag-p attr)))) | 1483 | (semantic-tagged (if (fboundp 'semantic-tag-p) |
| 1485 | (if semantic-tagged | 1484 | (semantic-tag-p attr)))) |
| 1486 | (with-no-warnings | 1485 | (if semantic-tagged |
| 1487 | (save-excursion | 1486 | (with-no-warnings |
| 1488 | (when (and (semantic-tag-overlay attr) | 1487 | (save-excursion |
| 1489 | (semantic-tag-buffer attr)) | 1488 | (when (and (semantic-tag-overlay attr) |
| 1490 | (set-buffer (semantic-tag-buffer attr))) | 1489 | (semantic-tag-buffer attr)) |
| 1491 | (dframe-message | 1490 | (set-buffer (semantic-tag-buffer attr))) |
| 1492 | (funcall semantic-sb-info-format-tag-function attr) | 1491 | (dframe-message |
| 1493 | ))) | 1492 | (funcall semantic-sb-info-format-tag-function attr) |
| 1494 | (looking-at "\\([0-9]+\\):") | 1493 | ))) |
| 1495 | (setq item (file-name-nondirectory (speedbar-line-directory))) | 1494 | (looking-at "\\([0-9]+\\):") |
| 1496 | (dframe-message "Tag: %s in %s" tag item))) | 1495 | (setq item (file-name-nondirectory (speedbar-line-directory))) |
| 1497 | (if (re-search-forward "{[+-]} \\([^\n]+\\)$" (line-end-position) t) | 1496 | (dframe-message "Tag: %s in %s" tag item)))) |
| 1498 | (dframe-message "Group of tags \"%s\"" (match-string 1)) | 1497 | ((re-search-forward "{[+-]} \\([^\n]+\\)$" (line-end-position) t) |
| 1499 | (if (re-search-forward " [+-]?[()|@] \\([^\n]+\\)$" nil t) | 1498 | (dframe-message "Group of tags \"%s\"" (match-string 1))) |
| 1500 | (let* ((detailtext (match-string 1)) | 1499 | ((re-search-forward " [+-]?[()|@] \\([^\n]+\\)$" nil t) |
| 1501 | (detail (or (speedbar-line-token) detailtext)) | 1500 | (let* ((detailtext (match-string 1)) |
| 1502 | (parent (save-excursion | 1501 | (detail (or (speedbar-line-token) detailtext)) |
| 1503 | (beginning-of-line) | 1502 | (parent (save-excursion |
| 1504 | (let ((dep (if (looking-at "[0-9]+:") | 1503 | (beginning-of-line) |
| 1505 | (1- (string-to-number (match-string 0))) | 1504 | (let ((dep (if (looking-at "[0-9]+:") |
| 1506 | 0))) | 1505 | (1- (string-to-number (match-string 0))) |
| 1507 | (re-search-backward (concat "^" | 1506 | 0))) |
| 1508 | (int-to-string dep) | 1507 | (re-search-backward (concat "^" |
| 1509 | ":") | 1508 | (int-to-string dep) |
| 1510 | nil t)) | 1509 | ":") |
| 1511 | (if (looking-at "[0-9]+: +[-+=>]> \\([^\n]+\\)$") | 1510 | nil t)) |
| 1512 | (speedbar-line-token) | 1511 | (if (looking-at "[0-9]+: +[-+=>]> \\([^\n]+\\)$") |
| 1513 | nil)))) | 1512 | (speedbar-line-token) |
| 1514 | (if (featurep 'semantic) | 1513 | nil)))) |
| 1515 | (with-no-warnings | 1514 | (cond |
| 1516 | (if (semantic-tag-p detail) | 1515 | ((featurep 'semantic) |
| 1517 | (dframe-message | 1516 | (with-no-warnings |
| 1518 | (funcall semantic-sb-info-format-tag-function detail parent)) | 1517 | (if (semantic-tag-p detail) |
| 1519 | (if parent | 1518 | (dframe-message |
| 1520 | (dframe-message "Detail: %s of tag %s" detail | 1519 | (funcall semantic-sb-info-format-tag-function detail parent)) |
| 1521 | (if (semantic-tag-p parent) | 1520 | (if parent |
| 1522 | (semantic-format-tag-name parent nil t) | 1521 | (dframe-message "Detail: %s of tag %s" detail |
| 1523 | parent)) | 1522 | (if (semantic-tag-p parent) |
| 1524 | (dframe-message "Detail: %s" detail)))) | 1523 | (semantic-format-tag-name parent nil t) |
| 1525 | ;; Not using `semantic': | 1524 | parent)) |
| 1526 | (if parent | 1525 | (dframe-message "Detail: %s" detail))))) |
| 1527 | (dframe-message "Detail: %s of tag %s" detail parent) | 1526 | ;; Not using `semantic': |
| 1528 | (dframe-message "Detail: %s" detail)))) | 1527 | (parent |
| 1529 | nil))))) | 1528 | (dframe-message "Detail: %s of tag %s" detail parent)) |
| 1529 | (t | ||
| 1530 | (dframe-message "Detail: %s" detail)))))))) | ||
| 1530 | 1531 | ||
| 1531 | (defun speedbar-files-item-info () | 1532 | (defun speedbar-files-item-info () |
| 1532 | "Display info in the minibuffer about the button the mouse is over." | 1533 | "Display info in the minibuffer about the button the mouse is over." |
| @@ -3388,9 +3389,7 @@ expanded. INDENT is the current indentation level." | |||
| 3388 | "Speedbar click handler for default directory buttons. | 3389 | "Speedbar click handler for default directory buttons. |
| 3389 | TEXT is the button clicked on. TOKEN is the directory to follow. | 3390 | TEXT is the button clicked on. TOKEN is the directory to follow. |
| 3390 | INDENT is the current indentation level and is unused." | 3391 | INDENT is the current indentation level and is unused." |
| 3391 | (if (string-match "^[A-Za-z]:$" token) | 3392 | (setq default-directory (file-name-as-directory token)) |
| 3392 | (setq default-directory (concat token "/")) | ||
| 3393 | (setq default-directory token)) | ||
| 3394 | ;; Because we leave speedbar as the current buffer, | 3393 | ;; Because we leave speedbar as the current buffer, |
| 3395 | ;; update contents will change directory without | 3394 | ;; update contents will change directory without |
| 3396 | ;; having to touch the attached frame. | 3395 | ;; having to touch the attached frame. |
| @@ -3964,7 +3963,7 @@ TEXT is the buffer's name, TOKEN and INDENT are unused." | |||
| 3964 | (speedbar-unhighlight-one-tag-line) | 3963 | (speedbar-unhighlight-one-tag-line) |
| 3965 | (setq speedbar-highlight-one-tag-line | 3964 | (setq speedbar-highlight-one-tag-line |
| 3966 | (speedbar-make-overlay (line-beginning-position) | 3965 | (speedbar-make-overlay (line-beginning-position) |
| 3967 | (1+ (line-end-position)))) | 3966 | (line-beginning-position 2))) |
| 3968 | (speedbar-overlay-put speedbar-highlight-one-tag-line 'face | 3967 | (speedbar-overlay-put speedbar-highlight-one-tag-line 'face |
| 3969 | 'speedbar-highlight-face) | 3968 | 'speedbar-highlight-face) |
| 3970 | (add-hook 'pre-command-hook 'speedbar-unhighlight-one-tag-line)) | 3969 | (add-hook 'pre-command-hook 'speedbar-unhighlight-one-tag-line)) |