Closed KhalfaniW closed 1 year ago
I wanted to autosave the persp to a file in the background but it kept showing a message.
I couldn't find a way to override the functonailty with inhibit-message because it affected other messages currently in the mini-buffer.
inhibit-message
So I just redefined the functions to not save with a message
(defun persp-save-with-backups (fname) "OVERWRITE persp file function to save silently " (when (and (string= fname (concat (expand-file-name persp-save-dir) persp-auto-save-fname)) (> persp-auto-save-num-of-backups 0)) (cl-do ((cur persp-auto-save-num-of-backups (1- cur)) (prev (1- persp-auto-save-num-of-backups) (1- prev))) ((> 1 cur) nil) (let ((cf (concat fname (number-to-string cur))) (pf (concat fname (if (> prev 0) (number-to-string prev) "")))) (when (file-exists-p pf) (when (file-exists-p cf) (delete-file cf)) (rename-file pf cf t)))) (when (file-exists-p fname) (rename-file fname (concat fname (number-to-string 1)) t))) (write-region (concat (buffer-string) "\n" ";;(setq current-os-dir (file-name-directory (buffer-file-name)) )" "\n" ) nil fname nil 'quiet)) (cl-defun persp-save-state-to-file (&optional (fname persp-auto-save-fname) (phash *persp-hash*) (respect-persp-file-parameter persp-auto-save-persps-to-their-file) (keep-others-in-non-parametric-file 'no)) (interactive (list (read-file-name "Save perspectives to a file: " persp-save-dir ""))) (when (and (stringp fname) phash) (when (< (string-width (file-name-nondirectory fname)) 1) (message "[persp-mode] Error: You must provide nonempty filename to save perspectives.") (cl-return-from persp-save-state-to-file nil)) (let* ((p-save-dir (or (file-name-directory fname) (expand-file-name persp-save-dir))) (p-save-file (concat p-save-dir (file-name-nondirectory fname)))) (unless (and (file-exists-p p-save-dir) (file-directory-p p-save-dir)) (message "[persp-mode] Info: Trying to create the `persp-conf-dir'.") (make-directory p-save-dir t)) (if (not (and (file-exists-p p-save-dir) (file-directory-p p-save-dir))) (progn (message "[persp-mode] Error: Can't save perspectives -- \ `persp-save-dir' does not exists or not a directory %S." p-save-dir) nil) (mapc #'persp-save-state (persp-persps phash)) (run-hook-with-args 'persp-before-save-state-to-file-functions fname phash respect-persp-file-parameter) (if (and respect-persp-file-parameter (cl-member-if (apply-partially #'persp-parameter 'persp-file) (persp-persps phash nil))) (let (persp-auto-save-persps-to-their-file persp-before-save-state-to-file-functions) (mapc #'(lambda (gr) (cl-destructuring-bind (pfname . pl) gr (let ((names (mapcar #'safe-persp-name pl))) (if pfname (persp-save-to-file-by-names pfname phash names 'yes nil) (persp-save-to-file-by-names p-save-file phash names keep-others-in-non-parametric-file nil))))) (persp-group-by (apply-partially #'persp-parameter 'persp-file) (persp-persps phash nil t) t))) (with-temp-buffer (buffer-disable-undo) (erase-buffer) (goto-char (point-min)) (insert ";;-*- mode: emacs-lisp; eval: (progn (pp-buffer) (indent-buffer)) -*-") (newline) (insert (let (print-length print-level) (pp-to-string (persps-to-savelist phash)))) (persp-save-with-backups p-save-file)))))))
I'm just leaving this hear for future reference for anyone with a similar problem
I wanted to autosave the persp to a file in the background but it kept showing a message.
I couldn't find a way to override the functonailty with
inhibit-message
because it affected other messages currently in the mini-buffer.So I just redefined the functions to not save with a message