Ini adalah modul yang saya tulis untuk .emacs saya sendiri untuk menyelesaikan masalah ini. Pendekatan dasar saya tampaknya mirip dengan maksud untuk solusi Maxim Kim (berputar melalui daftar tema), tetapi saya pikir milik saya lebih modular dan karena itu mungkin lebih mudah diakses oleh orang luar. Di sisi lain, saya tidak memiliki fitur kegigihan Kim.
Berikut adalah kode yang relevan, meninggalkan deklarasi variabel dan komentar paket:
(require 'dash)
(defun multitheme--enable (theme)
"As `enable-theme', but load the theme if necessary.
Respect `custom-safe-themes'."
(if (custom-theme-p theme)
(enable-theme theme)
(load-theme theme)))
(defun multitheme-cycle ()
"Cycle between the themes in `multitheme-base-theme-list'.
If none of these themes is currently active, instead enable the
first element of `multitheme-base-theme-list'.
Also re-enable `multitheme-overtheme' so it remains \"on top\" of
the base theme.
If a theme to be enabled is not yet defined, attempt to load it
first (using `load-theme'). Respect `custom-safe-themes'.
After all theme changes have been made, run
`multitheme-base-change-hook'."
(interactive)
(when (require 'validate nil :noerror)
(validate-variable 'multitheme-base-theme-list)
(validate-variable 'multitheme-overtheme)
(validate-variable 'multitheme-base-theme-change-hook))
(let ((themes (-drop-while
(lambda (thm) (not (custom-theme-enabled-p thm)))
multitheme-base-theme-list)))
;; Cycle base theme
(if (null themes)
(multitheme--enable (car multitheme-base-theme-list))
(disable-theme (car themes))
(multitheme--enable (or (cadr themes)
(car multitheme-base-theme-list))))
;; Reassert overtheme
(when multitheme-overtheme
(multitheme--enable multitheme-overtheme))
;; Run hooks
(run-hooks 'multitheme-base-theme-change-hook)))
(car custom-enabled-themes)
mengembalikan tema yang saat ini diaktifkan.