Function: plstore--encode

plstore--encode is a byte-compiled function defined in plstore.el.gz.

Signature

(plstore--encode PLSTORE)

Documentation

Return the printed representation of the decoded alist of PLSTORE.

Source Code

;; Defined in /usr/src/emacs/lisp/plstore.el.gz
;;; plstore mode.

;; The functions related to plstore mode unfortunately introduce yet
;; another alist format ("decoded alist").  After executing the "foo",
;; "bar", "baz" example from above the decoded alist of the plstore
;; would look like the following:
;;
;;   (("foo" :host "foo.example.org" :port 80)
;;    ("bar" :secret-user "test" :host "bar.example.org")
;;    ("baz" :secret-password "test" :host "baz.example.org"))
;;
;; Even more unfortunately, variable and function names of the
;; following are a bit mixed up IMHO: With the current names, the
;; result of function `plstore--encode' is used to create what is
;; presented as "decoded form of a plstore" to the user.  And variable
;; `plstore-encoded' is non-nil if a buffer shows the decoded form.

(defun plstore--encode (plstore)
  "Return the printed representation of the decoded alist of PLSTORE."
  (plstore--decrypt plstore)
  (let ((merged-alist (plstore--get-merged-alist plstore)))
    (concat "("
	    (mapconcat
	     (lambda (entry)
	       (setq entry (copy-sequence entry))
	       (let ((merged-plist (cdr (assoc (car entry) merged-alist)))
		     (plist (cdr entry)))
		 (while plist
		   (if (plstore--has-secret-keys plist)
		       (setcar (cdr plist)
			       (plist-get
				merged-plist
				(intern (concat ":"
						(substring (symbol-name
							    (car plist))
							   (match-end 0)))))))
		   (setq plist (nthcdr 2 plist)))
		 (prin1-to-string entry)))
	     (plstore--get-alist plstore)
	     "\n")
	    ")")))