diff options
author | Thierry Volpiatto <thierry.volpiatto@gmail.com> | 2016-04-08 06:35:58 +0200 |
---|---|---|
committer | Thierry Volpiatto <thierry.volpiatto@gmail.com> | 2016-04-08 06:35:58 +0200 |
commit | ca2f5bb273fddd2bb64ef28610a1531f14df0b8a (patch) | |
tree | 64817c338d9ee85f3af83bf749a804c4d15d877d | |
parent | 217d84fabb75b1d5c066f875261aaa2dde6d7ea7 (diff) |
Use setf slot-value everywhere.
-rw-r--r-- | helm-files.el | 13 | ||||
-rw-r--r-- | helm-org.el | 8 | ||||
-rw-r--r-- | helm-source.el | 103 | ||||
-rw-r--r-- | helm-types.el | 78 | ||||
-rw-r--r-- | helm.el | 2 |
5 files changed, 101 insertions, 103 deletions
diff --git a/helm-files.el b/helm-files.el index 1c5284ef..0cd464b2 100644 --- a/helm-files.el +++ b/helm-files.el @@ -3032,13 +3032,12 @@ Don't use it in your own code unless you know what you are doing.") (persistent-action :initform 'helm-ff-kill-or-find-buffer-fname))) (defmethod helm--setup-source :after ((source helm-recentf-source)) - (set-slot-value - source 'action - (append (symbol-value (helm-actions-from-type-file)) - '(("Delete file(s) from recentf" . - (lambda (_candidate) - (cl-loop for file in (helm-marked-candidates) - do (setq recentf-list (delq file recentf-list))))))))) + (setf (slot-value source 'action) + (append (symbol-value (helm-actions-from-type-file)) + '(("Delete file(s) from recentf" . + (lambda (_candidate) + (cl-loop for file in (helm-marked-candidates) + do (setq recentf-list (delq file recentf-list))))))))) (defvar helm-source-recentf nil "See (info \"(emacs)File Conveniences\"). diff --git a/helm-org.el b/helm-org.el index 20445f02..33b06956 100644 --- a/helm-org.el +++ b/helm-org.el @@ -133,10 +133,10 @@ Note this have no effect in `helm-org-in-buffer-headings'." (defmethod helm--setup-source :after ((source helm-org-headings-class)) (let ((parents (slot-value source 'parents))) - (set-slot-value source 'candidate-transformer - (lambda (candidates) - (let ((cands (helm-org-get-candidates candidates parents))) - (if parents (nreverse cands) cands)))))) + (setf (slot-value source 'candidate-transformer) + (lambda (candidates) + (let ((cands (helm-org-get-candidates candidates parents))) + (if parents (nreverse cands) cands)))))) (defun helm-source-org-headings-for-files (filenames &optional parents) (helm-make-source "Org Headings" 'helm-org-headings-class diff --git a/helm-source.el b/helm-source.el index a39ad869..6510620a 100644 --- a/helm-source.el +++ b/helm-source.el @@ -759,14 +759,14 @@ Argument CLASS is an eieio class object. Arguments ARGS are keyword value pairs as defined in CLASS." (declare (indent 2)) (let ((source (apply #'make-instance class name args))) - (set-slot-value source 'name name) + (setf (slot-value source 'name) name) (helm--setup-source source) (helm-setup-user-source source) (helm--create-source source))) (defun helm-make-type (class &rest args) (let ((source (apply #'make-instance class args))) - (set-slot-value source 'name nil) + (setf (slot-value source 'name) nil) (helm--setup-source source) (helm--create-source source))) @@ -819,14 +819,12 @@ an eieio class." actions (quote ,new-action) ,index)) (t actions))))) (if (functionp actions) - (set-slot-value source 'action (list (cons "Default action" actions))) - (set-slot-value source 'action (helm-interpret-value actions source))) + (setf (slot-value source 'action) (list (cons "Default action" actions))) + (setf (slot-value source 'action) (helm-interpret-value actions source))) (when (or (symbolp action-transformers) (functionp action-transformers)) (setq action-transformers (list action-transformers))) - (set-slot-value - source - 'action-transformer - (delq nil (append (list transformer) action-transformers))))) + (setf (slot-value source 'action-transformer) + (delq nil (append (list transformer) action-transformers))))) ;;; Methods to build sources. @@ -875,74 +873,75 @@ an eieio class." (warn "Deprecated usage of helm `delayed' slot in `%s'" (slot-value source 'name))) (helm-aif (slot-value source 'keymap) - (and (symbolp it) (set-slot-value source 'keymap (symbol-value it)))) + (and (symbolp it) (setf (slot-value source 'keymap) (symbol-value it)))) (helm-aif (slot-value source 'persistent-help) - (set-slot-value source 'header-line - (helm-source--persistent-help-string it source)) - (set-slot-value source 'header-line (helm-source--header-line source))) + (setf (slot-value source 'header-line) + (helm-source--persistent-help-string it source)) + (setf (slot-value source 'header-line) (helm-source--header-line source))) (helm-aif (slot-value source 'candidate-number-limit) - (and (symbolp it) (set-slot-value - source 'candidate-number-limit (symbol-value it)))) + (and (symbolp it) (setf (slot-value source 'candidate-number-limit) + (symbol-value it)))) (when (and (slot-value source 'fuzzy-match) helm-fuzzy-sort-fn) - (set-slot-value source 'filtered-candidate-transformer - (helm-aif (slot-value source 'filtered-candidate-transformer) - (append (helm-mklist it) - (list helm-fuzzy-sort-fn)) - (list helm-fuzzy-sort-fn)))) + (setf (slot-value source 'filtered-candidate-transformer) + (helm-aif (slot-value source 'filtered-candidate-transformer) + (append (helm-mklist it) + (list helm-fuzzy-sort-fn)) + (list helm-fuzzy-sort-fn)))) (unless (slot-value source 'nohighlight) - (set-slot-value source 'filtered-candidate-transformer - (helm-aif (slot-value source 'filtered-candidate-transformer) - (append (helm-mklist it) - (list #'helm-fuzzy-highlight-matches)) - (list #'helm-fuzzy-highlight-matches))))) + (setf (slot-value source 'filtered-candidate-transformer) + (helm-aif (slot-value source 'filtered-candidate-transformer) + (append (helm-mklist it) + (list #'helm-fuzzy-highlight-matches)) + (list #'helm-fuzzy-highlight-matches))))) (defmethod helm-setup-user-source ((_source helm-source))) (defmethod helm--setup-source ((source helm-source-sync)) (when (slot-value source 'fuzzy-match) (helm-aif (slot-value source 'match) - (set-slot-value source 'match (append (helm-mklist it) - (list helm-fuzzy-match-fn))) - (set-slot-value source 'match helm-fuzzy-match-fn))) + (setf (slot-value source 'match) + (append (helm-mklist it) + (list helm-fuzzy-match-fn))) + (setf (slot-value source 'match) helm-fuzzy-match-fn))) (when (slot-value source 'matchplugin) - (set-slot-value source 'match - (helm-source-mm-get-search-or-match-fns source 'match))) + (setf (slot-value source 'match) + (helm-source-mm-get-search-or-match-fns source 'match))) (helm-aif (and (null (slot-value source 'matchplugin)) (slot-value source 'migemo)) (unless (eq it 'nomultimatch) ; Use own migemo fn. - (set-slot-value source 'match - (append (helm-mklist (slot-value source 'match)) - '(helm-mm-3-migemo-match)))))) + (setf (slot-value source 'match) + (append (helm-mklist (slot-value source 'match)) + '(helm-mm-3-migemo-match)))))) (defmethod helm--setup-source ((source helm-source-in-buffer)) (let ((cur-init (slot-value source 'init))) (helm-aif (slot-value source 'data) - (set-slot-value - source - 'init (delq - nil - (list - (and (null (eq 'helm-default-init-source-in-buffer-function - cur-init)) - cur-init) - (lambda () - (helm-init-candidates-in-buffer - 'global - (if (functionp it) (funcall it) it)))))))) + (setf (slot-value source 'init) + (delq + nil + (list + (and (null (eq 'helm-default-init-source-in-buffer-function + cur-init)) + cur-init) + (lambda () + (helm-init-candidates-in-buffer + 'global + (if (functionp it) (funcall it) it)))))))) (when (slot-value source 'fuzzy-match) (helm-aif (slot-value source 'search) - (set-slot-value source 'search (append (helm-mklist it) - (list helm-fuzzy-search-fn))) - (set-slot-value source 'search (list helm-fuzzy-search-fn)))) + (setf (slot-value source 'search) + (append (helm-mklist it) + (list helm-fuzzy-search-fn))) + (setf (slot-value source 'search) (list helm-fuzzy-search-fn)))) (when (slot-value source 'matchplugin) - (set-slot-value - source 'search (helm-source-mm-get-search-or-match-fns source 'search))) + (setf (slot-value source 'search) + (helm-source-mm-get-search-or-match-fns source 'search))) (helm-aif (and (null (slot-value source 'matchplugin)) (slot-value source 'migemo)) (unless (eq it 'nomultimatch) - (set-slot-value source 'search - (append (helm-mklist (slot-value source 'search)) - '(helm-mm-3-migemo-search))))) + (setf (slot-value source 'search) + (append (helm-mklist (slot-value source 'search)) + '(helm-mm-3-migemo-search))))) (let ((mtc (slot-value source 'match))) (cl-assert (or (equal '(identity) mtc) (eq 'identity mtc)) diff --git a/helm-types.el b/helm-types.el index f3236eb4..670ecf48 100644 --- a/helm-types.el +++ b/helm-types.el @@ -71,17 +71,19 @@ (defmethod helm--setup-source :primary ((_source helm-type-file))) (defmethod helm--setup-source :before ((source helm-type-file)) - (set-slot-value source 'action 'helm-type-file-actions) - (set-slot-value source 'persistent-help "Show this file") - (set-slot-value source 'action-transformer '(helm-transform-file-load-el - helm-transform-file-browse-url - helm-transform-file-cache)) - (set-slot-value source 'candidate-transformer '(helm-skip-boring-files - helm-highlight-files - helm-w32-pathname-transformer)) - (set-slot-value source 'help-message 'helm-generic-file-help-message) - (set-slot-value source 'mode-line (list "File(s)" helm-mode-line-string)) - (set-slot-value source 'keymap helm-generic-files-map)) + (setf (slot-value source 'action) 'helm-type-file-actions) + (setf (slot-value source 'persistent-help) "Show this file") + (setf (slot-value source 'action-transformer) + '(helm-transform-file-load-el + helm-transform-file-browse-url + helm-transform-file-cache)) + (setf (slot-value source 'candidate-transformer) + '(helm-skip-boring-files + helm-highlight-files + helm-w32-pathname-transformer)) + (setf (slot-value source 'help-message) 'helm-generic-file-help-message) + (setf (slot-value source 'mode-line) (list "File(s)" helm-mode-line-string)) + (setf (slot-value source 'keymap) helm-generic-files-map)) ;; Bookmarks @@ -109,11 +111,11 @@ (defmethod helm--setup-source :primary ((_source helm-type-bookmark))) (defmethod helm--setup-source :before ((source helm-type-bookmark)) - (set-slot-value source 'action 'helm-type-bookmark-actions) - (set-slot-value source 'keymap helm-bookmark-map) - (set-slot-value source 'mode-line (list "Bookmark(s)" helm-mode-line-string)) - (set-slot-value source 'help-message 'helm-bookmark-help-message) - (set-slot-value source 'migemo t)) + (setf (slot-value source 'action) 'helm-type-bookmark-actions) + (setf (slot-value source 'keymap) helm-bookmark-map) + (setf (slot-value source 'mode-line) (list "Bookmark(s)" helm-mode-line-string)) + (setf (slot-value source 'help-message) 'helm-bookmark-help-message) + (setf (slot-value source 'migemo) t)) ;; Buffers @@ -159,14 +161,13 @@ (defmethod helm--setup-source :primary ((_source helm-type-buffer))) (defmethod helm--setup-source :before ((source helm-type-buffer)) - (set-slot-value source 'action 'helm-type-buffer-actions) - (set-slot-value source 'persistent-help "Show this buffer") - (set-slot-value source 'mode-line (list "Buffer(s)" helm-mode-line-string)) - (set-slot-value - source 'filtered-candidate-transformer - '(helm-skip-boring-buffers - helm-buffers-sort-transformer - helm-highlight-buffers))) + (setf (slot-value source 'action) 'helm-type-buffer-actions) + (setf (slot-value source 'persistent-help) "Show this buffer") + (setf (slot-value source 'mode-line) (list "Buffer(s)" helm-mode-line-string)) + (setf (slot-value source 'filtered-candidate-transformer) + '(helm-skip-boring-buffers + helm-buffers-sort-transformer + helm-highlight-buffers))) ;; Functions (defclass helm-type-function (helm-source) () @@ -197,12 +198,12 @@ (defmethod helm--setup-source :primary ((_source helm-type-function))) (defmethod helm--setup-source :before ((source helm-type-function)) - (set-slot-value source 'action 'helm-type-function-actions) - (set-slot-value source 'action-transformer - 'helm-transform-function-call-interactively) - (set-slot-value source 'candidate-transformer - 'helm-mark-interactive-functions) - (set-slot-value source 'coerce 'helm-symbolify)) + (setf (slot-value source 'action) 'helm-type-function-actions) + (setf (slot-value source 'action-transformer) + 'helm-transform-function-call-interactively) + (setf (slot-value source 'candidate-transformer) + 'helm-mark-interactive-functions) + (setf (slot-value source 'coerce) 'helm-symbolify)) ;; Commands @@ -225,10 +226,9 @@ (defmethod helm--setup-source :primary ((_source helm-type-command))) (defmethod helm--setup-source :before ((source helm-type-command)) - (set-slot-value - source 'action 'helm-type-command-actions) - (set-slot-value source 'coerce 'helm-symbolify) - (set-slot-value source 'persistent-action 'describe-function)) + (setf (slot-value source 'action) 'helm-type-command-actions) + (setf (slot-value source 'coerce) 'helm-symbolify) + (setf (slot-value source 'persistent-action) 'describe-function)) ;; Timers (defclass helm-type-timers (helm-source) () @@ -253,11 +253,11 @@ (defmethod helm--setup-source :primary ((_source helm-type-timers))) (defmethod helm--setup-source :before ((source helm-type-timers)) - (set-slot-value source 'action 'helm-type-timers-actions) - (set-slot-value source 'persistent-action - (lambda (tm) - (describe-function (timer--function tm)))) - (set-slot-value source 'persistent-help "Describe Function")) + (setf (slot-value source 'action) 'helm-type-timers-actions) + (setf (slot-value source 'persistent-action) + (lambda (tm) + (describe-function (timer--function tm)))) + (setf (slot-value source 'persistent-help) "Describe Function")) ;; Builders. (defun helm-build-type-file () @@ -5382,7 +5382,7 @@ If the source is defined with its own class, you can use `helm-setup-user-source' e.g: (defmethod helm-setup-user-source ((source helm-grep-class)) - (set-slot-value source 'follow 1)) + (setf (slot-value source 'follow) 1)) Otherwise, use `helm-attrset' to setup the `follow' attribute of the existing source, which see. |