diff --git a/test/whale-line-segments-test.el b/test/whale-line-segments-test.el index d6c5d92..cbf1957 100644 --- a/test/whale-line-segments-test.el +++ b/test/whale-line-segments-test.el @@ -54,7 +54,8 @@ (ert-deftest buffer-identification--path-segments () :tags '(segments buffer) - (bydi ((:mock buffer-file-name :return "/test/one/two/three.el")) + (bydi ((:mock buffer-file-name :return "/test/one/two/three.el") + (:mock buffer-name :return "three.el")) (let ((whale-line-segments-buffer-identification-path-segments 1)) diff --git a/whale-line-segments.el b/whale-line-segments.el index 7e19db5..ccaee92 100644 --- a/whale-line-segments.el +++ b/whale-line-segments.el @@ -132,9 +132,16 @@ This pre-pends the path to the buffer if so configured." (list 'help-echo whale-line-segments--buffer-identification--additional-help))))) (defun whale-line-segments--buffer-identification--path-segments () - "Get preceding path segments." + "Get preceding path segments. + +This can be disabled by setting +`whale-line-segments-buffer-identification-path-segments' to a +non-positive value. + +Buffers that have been renamed will also yield no segments." (and-let* (((> whale-line-segments-buffer-identification-path-segments 0)) - (file (buffer-file-name (current-buffer))) + (file (buffer-file-name)) + ((string= (buffer-name) (file-name-nondirectory file))) (path (file-name-split file)) (count (min (1- (length path)) whale-line-segments-buffer-identification-path-segments)) (segments (seq-take (cdr (reverse path)) count)))