Fix move/state persistence, use switch-to-buffer for screen reader

- Use setq with plist-put everywhere to ensure state changes persist
  (quoted list literals may be read-only in some Emacs builds)
- Replace pop-to-buffer with switch-to-buffer so the RPG buffer opens
  in the current window instead of a Doom popup — screen reader reads
  it as a normal buffer, not a completion overlay

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-03-24 15:17:46 +01:00
parent 9ebffa1a43
commit a6c02a6969

View File

@@ -818,9 +818,9 @@
(setq alien-rpg-state-file file) (setq alien-rpg-state-file file)
;; Zpětná kompatibilita — doplnit chybějící klíče ;; Zpětná kompatibilita — doplnit chybějící klíče
(unless (plist-member alien-rpg-state :conditions) (unless (plist-member alien-rpg-state :conditions)
(plist-put alien-rpg-state :conditions nil)) (setq alien-rpg-state (plist-put alien-rpg-state :conditions nil)))
(unless (plist-member alien-rpg-state :armor) (unless (plist-member alien-rpg-state :armor)
(plist-put alien-rpg-state :armor nil)) (setq alien-rpg-state (plist-put alien-rpg-state :armor nil)))
(message "Načteno: %s" file)))) (message "Načteno: %s" file))))
(defun alien-rpg--autosave () (defun alien-rpg--autosave ()
@@ -897,7 +897,7 @@
deck-ids ", ")))))) deck-ids ", "))))))
(goto-char (point-min)) (goto-char (point-min))
(special-mode)) (special-mode))
(pop-to-buffer "*Alien RPG*"))) (switch-to-buffer "*Alien RPG*")))
(defun alien-rpg-move () (defun alien-rpg-move ()
"Přesun do propojené místnosti." "Přesun do propojené místnosti."
@@ -911,7 +911,7 @@
(format "%s -> " (plist-get room :id)) (format "%s -> " (plist-get room :id))
candidates nil t)) candidates nil t))
(target-id (cdr (assoc choice candidates)))) (target-id (cdr (assoc choice candidates))))
(plist-put alien-rpg-state :current-room target-id) (setq alien-rpg-state (plist-put alien-rpg-state :current-room target-id))
(alien-rpg--autosave) (alien-rpg--autosave)
(alien-rpg-where-am-i))) (alien-rpg-where-am-i)))
@@ -923,7 +923,7 @@
alien-rpg-rooms)) alien-rpg-rooms))
(choice (completing-read "Teleport: " candidates nil t)) (choice (completing-read "Teleport: " candidates nil t))
(target-id (cdr (assoc choice candidates)))) (target-id (cdr (assoc choice candidates))))
(plist-put alien-rpg-state :current-room target-id) (setq alien-rpg-state (plist-put alien-rpg-state :current-room target-id))
(alien-rpg--autosave) (alien-rpg--autosave)
(alien-rpg-where-am-i))) (alien-rpg-where-am-i)))
@@ -987,7 +987,7 @@
deck-ids ", ")))))) deck-ids ", "))))))
(goto-char (point-min)) (goto-char (point-min))
(special-mode)) (special-mode))
(pop-to-buffer "*Alien RPG*"))) (switch-to-buffer "*Alien RPG*")))
(defun alien-rpg-find-path () (defun alien-rpg-find-path ()
"Všechny nejkratší cesty do cíle." "Všechny nejkratší cesty do cíle."
@@ -1028,7 +1028,7 @@
(insert "Cesta nenalezena.\n"))) (insert "Cesta nenalezena.\n")))
(goto-char (point-min)) (goto-char (point-min))
(special-mode)) (special-mode))
(pop-to-buffer "*Alien RPG*"))) (switch-to-buffer "*Alien RPG*")))
(defun alien-rpg-deck-overview () (defun alien-rpg-deck-overview ()
"Přehled paluby." "Přehled paluby."
@@ -1053,7 +1053,7 @@
(plist-get r :location))))) (plist-get r :location)))))
(goto-char (point-min)) (goto-char (point-min))
(special-mode)) (special-mode))
(pop-to-buffer "*Alien RPG*"))) (switch-to-buffer "*Alien RPG*")))
(defun alien-rpg-station-overview () (defun alien-rpg-station-overview ()
"Přehled stanice." "Přehled stanice."
@@ -1074,7 +1074,7 @@
("H" (insert " (průlezy G<->H)\n ---\n")))))) ("H" (insert " (průlezy G<->H)\n ---\n"))))))
(goto-char (point-min)) (goto-char (point-min))
(special-mode)) (special-mode))
(pop-to-buffer "*Alien RPG*"))) (switch-to-buffer "*Alien RPG*")))
(defun alien-rpg-key-locations () (defun alien-rpg-key-locations ()
"Klíčová místa." "Klíčová místa."
@@ -1100,7 +1100,7 @@ Průlezy G<->H: G3<->H3, G4<->H4, G7<->H7, G8<->H8, G9<->H9
")) "))
(goto-char (point-min)) (goto-char (point-min))
(special-mode)) (special-mode))
(pop-to-buffer "*Alien RPG*")) (switch-to-buffer "*Alien RPG*"))
(defun alien-rpg-status () (defun alien-rpg-status ()
"Stav postavy — stručně." "Stav postavy — stručně."
@@ -1159,7 +1159,7 @@ Průlezy G<->H: G3<->H3, G4<->H4, G7<->H7, G8<->H8, G9<->H9
(or (plist-get alien-rpg-state :rival) "--")))) (or (plist-get alien-rpg-state :rival) "--"))))
(goto-char (point-min)) (goto-char (point-min))
(special-mode)) (special-mode))
(pop-to-buffer "*Alien RPG*"))) (switch-to-buffer "*Alien RPG*")))
(defun alien-rpg-skills () (defun alien-rpg-skills ()
"Dovednosti — seřazené od nejsilnějších." "Dovednosti — seřazené od nejsilnějších."
@@ -1191,37 +1191,37 @@ Průlezy G<->H: G3<->H3, G4<->H4, G7<->H7, G8<->H8, G9<->H9
(insert (format "\nTalent: %s\n" (plist-get alien-rpg-character :talent)))) (insert (format "\nTalent: %s\n" (plist-get alien-rpg-character :talent))))
(goto-char (point-min)) (goto-char (point-min))
(special-mode)) (special-mode))
(pop-to-buffer "*Alien RPG*"))) (switch-to-buffer "*Alien RPG*")))
;; --- Upravy stavu --- ;; --- Upravy stavu ---
(defun alien-rpg-set-health (n) (defun alien-rpg-set-health (n)
"Nastav Health." "Nastav Health."
(interactive "nHealth (0-4): ") (interactive "nHealth (0-4): ")
(plist-put alien-rpg-state :health (max 0 (min 4 n))) (setq alien-rpg-state (plist-put alien-rpg-state :health (max 0 (min 4 n))))
(alien-rpg--autosave) (alien-rpg--autosave)
(message "Health: %d/4" (plist-get alien-rpg-state :health))) (message "Health: %d/4" (plist-get alien-rpg-state :health)))
(defun alien-rpg-set-stress (n) (defun alien-rpg-set-stress (n)
"Nastav Stress." "Nastav Stress."
(interactive "nStress (0+): ") (interactive "nStress (0+): ")
(plist-put alien-rpg-state :stress (max 0 n)) (setq alien-rpg-state (plist-put alien-rpg-state :stress (max 0 n)))
(alien-rpg--autosave) (alien-rpg--autosave)
(message "Stress: %d" (plist-get alien-rpg-state :stress))) (message "Stress: %d" (plist-get alien-rpg-state :stress)))
(defun alien-rpg-add-injury (injury) (defun alien-rpg-add-injury (injury)
"Přidej zranění." "Přidej zranění."
(interactive "sZranění: ") (interactive "sZranění: ")
(plist-put alien-rpg-state :injuries (setq alien-rpg-state (plist-put alien-rpg-state :injuries
(append (plist-get alien-rpg-state :injuries) (list injury))) (append (plist-get alien-rpg-state :injuries) (list injury))))
(alien-rpg--autosave) (alien-rpg--autosave)
(message "Zranění: %s" injury)) (message "Zranění: %s" injury))
(defun alien-rpg-add-gear (item) (defun alien-rpg-add-gear (item)
"Přidej výbavu." "Přidej výbavu."
(interactive "sVýbava: ") (interactive "sVýbava: ")
(plist-put alien-rpg-state :extra-gear (setq alien-rpg-state (plist-put alien-rpg-state :extra-gear
(append (plist-get alien-rpg-state :extra-gear) (list item))) (append (plist-get alien-rpg-state :extra-gear) (list item))))
(alien-rpg--autosave) (alien-rpg--autosave)
(message "Výbava: %s" item)) (message "Výbava: %s" item))
@@ -1236,8 +1236,8 @@ Průlezy G<->H: G3<->H3, G4<->H4, G7<->H7, G8<->H8, G9<->H9
(weight (read-number "Weight: " 1)) (weight (read-number "Weight: " 1))
(weapon (list :name name :bonus bonus :damage damage (weapon (list :name name :bonus bonus :damage damage
:range range :ammo ammo :weight weight))) :range range :ammo ammo :weight weight)))
(plist-put alien-rpg-state :weapons (setq alien-rpg-state (plist-put alien-rpg-state :weapons
(append (plist-get alien-rpg-state :weapons) (list weapon))) (append (plist-get alien-rpg-state :weapons) (list weapon))))
(alien-rpg--autosave) (alien-rpg--autosave)
(message "Zbraň: %s +%d/DMG%d/%s" name bonus damage range))) (message "Zbraň: %s +%d/DMG%d/%s" name bonus damage range)))
@@ -1248,7 +1248,7 @@ Průlezy G<->H: G3<->H3, G4<->H4, G7<->H7, G8<->H8, G9<->H9
(rating (read-number "Rating: " 1)) (rating (read-number "Rating: " 1))
(weight (read-number "Weight: " 1)) (weight (read-number "Weight: " 1))
(armor (list :name name :rating rating :weight weight))) (armor (list :name name :rating rating :weight weight)))
(plist-put alien-rpg-state :armor armor) (setq alien-rpg-state (plist-put alien-rpg-state :armor armor))
(alien-rpg--autosave) (alien-rpg--autosave)
(message "Brnění: %s (%d/W%d)" name rating weight))) (message "Brnění: %s (%d/W%d)" name rating weight)))
@@ -1256,31 +1256,31 @@ Průlezy G<->H: G3<->H3, G4<->H4, G7<->H7, G8<->H8, G9<->H9
"Přidej stav (Fatigued, Radiation, ...)." "Přidej stav (Fatigued, Radiation, ...)."
(interactive) (interactive)
(let ((cond-name (read-string "Stav: "))) (let ((cond-name (read-string "Stav: ")))
(plist-put alien-rpg-state :conditions (setq alien-rpg-state (plist-put alien-rpg-state :conditions
(append (plist-get alien-rpg-state :conditions) (list cond-name))) (append (plist-get alien-rpg-state :conditions) (list cond-name))))
(alien-rpg--autosave) (alien-rpg--autosave)
(message "Stav: %s" cond-name))) (message "Stav: %s" cond-name)))
(defun alien-rpg-set-buddy (name) (defun alien-rpg-set-buddy (name)
"Nastav Buddy." "Nastav Buddy."
(interactive "sBuddy: ") (interactive "sBuddy: ")
(plist-put alien-rpg-state :buddy name) (setq alien-rpg-state (plist-put alien-rpg-state :buddy name))
(alien-rpg--autosave) (alien-rpg--autosave)
(message "Buddy: %s" name)) (message "Buddy: %s" name))
(defun alien-rpg-set-rival (name) (defun alien-rpg-set-rival (name)
"Nastav Rivala." "Nastav Rivala."
(interactive "sRival: ") (interactive "sRival: ")
(plist-put alien-rpg-state :rival name) (setq alien-rpg-state (plist-put alien-rpg-state :rival name))
(alien-rpg--autosave) (alien-rpg--autosave)
(message "Rival: %s" name)) (message "Rival: %s" name))
(defun alien-rpg-add-note (note) (defun alien-rpg-add-note (note)
"Přidej poznámku." "Přidej poznámku."
(interactive "sPoznamka: ") (interactive "sPoznamka: ")
(plist-put alien-rpg-state :notes (setq alien-rpg-state (plist-put alien-rpg-state :notes
(append (plist-get alien-rpg-state :notes) (append (plist-get alien-rpg-state :notes)
(list (format "[%s] %s" (format-time-string "%H:%M") note)))) (list (format "[%s] %s" (format-time-string "%H:%M") note)))))
(alien-rpg--autosave) (alien-rpg--autosave)
(message "Poznámka uložena.")) (message "Poznámka uložena."))
@@ -1296,7 +1296,7 @@ Průlezy G<->H: G3<->H3, G4<->H4, G7<->H7, G8<->H8, G9<->H9
(insert "(žádné poznámky)\n"))) (insert "(žádné poznámky)\n")))
(goto-char (point-min)) (goto-char (point-min))
(special-mode)) (special-mode))
(pop-to-buffer "*Alien RPG*")) (switch-to-buffer "*Alien RPG*"))
;; ==================================================================== ;; ====================================================================
;; DOOM EMACS KEYBINDINGS ;; DOOM EMACS KEYBINDINGS