[TriLUG] Display full file path in emacs

Tom Bryan tbryan at python.net
Wed Jul 24 18:24:03 EDT 2002


On Wednesday 24 July 2002 03:41 pm, Zhaoning Li wrote:
> Hi,
>
> I use emacs to edit source code in different trees. But by default,
> emacs just displays the file name in its mode line. If two files have
> the same name, it addes <num> after the file name. So I am wondering if
> there is a way to let emacs display the full file path in its mode
> instead of just file name. Can anyone help me? Thank you!

M-x customize-group RET uniquify RET
You probably want to adjust the buffer name style.  Note that if you have 
directories that are long and only distinguished by an early component of the 
filename, such as 
ver1/com/zhaoning/util/DateRange.java
ver2/com/zhaoning/util/DateRange.java

much of the info on your modeline may be pushed out of your visible view.

Also try a search for 
xemacs modeline "full path"
will pull back other possibilities, such as using the titlebar with the 
following code in your .emacs file

;;; ********************
;;; Determine emacsen flavor
;;;

;; Define a variable to indicate whether we're running XEmacs/Lucid Emacs.
(defvar running-xemacs (string-match "XEmacs\\|Lucid" emacs-version))

;; Older versions of emacs did not have these variables
;; (emacs-major-version and emacs-minor-version.)  Let's define them
;; if they're not around, since they make it much easier to
;; conditionalize on the emacs version.

(if (and (not (boundp 'emacs-major-version))
         (string-match "^[0-9]+" emacs-version))
    (setq emacs-major-version
          (string-to-int (substring emacs-version
                                    (match-beginning 0) (match-end 0)))))
(if (and (not (boundp 'emacs-minor-version))
         (string-match "^[0-9]+\\.\\([0-9]+\\)" emacs-version))
    (setq emacs-minor-version
          (string-to-int (substring emacs-version
                                    (match-beginning 1) (match-end 1)))))

;; Define a function to make it easier to check which version we're
;; running.

(defun running-emacs-version-or-newer (major minor)
  (or (> emacs-major-version major)
      (and (= emacs-major-version major)
         (>= emacs-minor-version minor))))

;; This variable didn't exist in pre 21.1 versions, but its nice to
;; have to set the title bar text.

(if (not (boundp 'emacs-program-version))
    (setq emacs-program-version
     (concat (int-to-string emacs-major-version)"."
              (int-to-string emacs-minor-version))))

;;; ********************
;;; XEmacs specific stuff
;;;
(cond (running-xemacs
       (cond ((or (not (fboundp 'device-type))
                  (equal (device-type) 'x))
          ;; Code which applies only when running emacs under X goes here.
          ;; (We check whether the function `device-type' exists
          ;; before using it.  In versions before 19.12, there was no
          ;; such function.  If it doesn't exist, we simply assume
          ;; we're running under X -- versions before 19.12 only
          ;; supported X.)

          ;; This changes the variable which controls the text that
          ;; goes in the top window title bar.  (However, it is not
          ;; changed unless it currently has the default value, to
          ;; avoid interfering with a -wn command line argument emacs
          ;; may have been started with.)
          (if (equal frame-title-format "%S: %b")
              (setq frame-title-format
                    (concat "XEmacs "
                            "["emacs-program-version"]"
                            ": %f"))
            )
          ))
))

---Tom




More information about the TriLUG mailing list