I wrote a function that pastes in the currently selected color from the palette to the buffer:

(defun palette-paste-in-current-color ()
  (cua-paste (palette-current-rgb-to-kill-ring)))

I wrote a function that calls the palette from the current content of the kill ring (RGB content):

(defun palette-launch-from-kill-ring ()
  (palette (concat "#" (substring-no-properties (car kill-ring)))))

I thought it would be handy to just move the point to an rgb color in a buffer, then use expand-region followed by cua-copy-region to automate the process. So I wrote:

(defun palette-launch-from-kill-ring ()
  (palette (concat "#" (substring-no-properties (car kill-ring)))))

But I get an error and I am puzzled on how to run these functions one after another successfully.


The error I get is (can't decipher what is going on here):

apply: Wrong number of arguments: #[(ad--addoit-function arg) "Ä        Å 
!)" [ad-return-value rectangular-region-mode ad--addoit-function arg nil rrm/switch-to-multiple-cursors] 3], 1
  • What is the error you get? Perhaps the region was no longer active and it needed to be? If so, set mark-active. More importantly, you should not need to use the kill ring at all, here (unless you really need to have such text on it, for some other use later). Just pass the text of the region around where you need it: buffer-substring, region-beginning, region-end. – Drew Nov 26 '16 at 0:38
  • @Drew I just updated the post and included the error message. I'll try to sort it out now with mark-active. I probably should just learn elisp properly! – Damian Chrzanowski Nov 26 '16 at 8:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.