Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adds a customization for how much of the filename gets truncated #289

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions go-guru.el
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@
:type 'string
:group 'go-guru)

(defcustom go-guru-truncate-file-length 20
"The length to truncate the file name to in the output buffer."
:type 'integer
:group 'go-guru)

(defvar go-guru--scope-history
nil
"History of values supplied to `go-guru-set-scope'.")
Expand Down Expand Up @@ -231,9 +236,10 @@ output of the Go guru tool."
(setq p (1- p)) ; exclude final space
(let* ((posn (buffer-substring-no-properties start p))
(flen (cl-search ":" posn)) ; length of filename
(filename (if (< flen 19)
(truncate (- (max go-guru-truncate-file-length 20) 1))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand the use of max here. Can we not truncate to less than 20 characters?

(filename (if (< flen truncate)
(substring posn 0 flen)
(concat "…" (substring posn (- flen 19) flen)))))
(concat "…" (substring posn (- flen truncate) flen)))))
(put-text-property start p 'display filename)
(forward-line 1)
(setq start (point))))))))
Expand Down