Skip to content

Questions about auto-mode-alist settings #141

Description

@eki3z

I have settings as below:

(setq-default major-mode
              (lambda () (if buffer-file-name
                             (fundamental-mode)
                           (let ((buffer-file-name (buffer-name)))
                             (set-auto-mode)))))

when it's a file-visiting buffer, set default to fundamental-mode, when it's not, set major-mode according to auto-mode-alist. And it's doing well until I edit a new buffer ".gitconfig", it failed. I see these code

;;;###autoload
(dolist (pattern '("/\\.gitconfig\\'"      "/\\.git/config\\'"
                   "/modules/.*/config\\'" "/git/config\\'"
                   "/\\.gitmodules\\'"     "/etc/gitconfig\\'"))
  (add-to-list 'auto-mode-alist (cons pattern 'gitconfig-mode)))

Of course it's no problem , but I just doubt what difference between "/\\.gitconfig\\'" and "\\.gitconfig\\'" ?
with latter, my major-mdoe setting is OK, the former couldn't apply to a buffer which is no-file-visiting.
Is there a improvement ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions