Question: I want to access any current file quickly. Therefore I want to build a function that put a file the register. 

I've started with this function:

```
(defun tmp-register ()
""" put the current buffer in the temporary register """
(interactive)
(set-register , ?q  (file . buffer-file-name))
)

```

but it fails as expected as I need a string instead of `buffer-file-name`. Do you see a way around this?

**Update** 

I have tweaked some code from Sacha Chua [here](http://pages.sachachua.com/.emacs.d/Sacha.html#babel-init). I've come up with this. I don't understand it entirely yet and it can probably be improved. Do you have something else in mind?

```
(defun tmp-register ()
""" put the current buffer in the temporary register """
(interactive)
(my/defshortcut ?q buffer-file-name)
)

(defvar my/refile-map (make-sparse-keymap))
(defmacro my/defshortcut (key file)
  `(progn
    (set-register ,key (cons 'file ,file))
 (define-key my/refile-map
   (char-to-string ,key)
   (lambda (prefix)
     (interactive "p")
     (let ((org-refile-targets '(((,file) :maxlevel . 6)))
           (current-prefix-arg (or current-prefix-arg '(4))))
       (call-interactively 'org-refile))))))

(global-set-key (kbd "<f12>") 'tmp-register)

```

Answer: 
OK, I have updated my answer to save the file being visited by the current buffer.

Try this slight variation on your original function:

```
 (defun tmp-register ()
  """ put the current buffer in the temporary register """
  (interactive)
  (set-register ?q (cons 'file buffer-file-name)))

```

After calling this function (with `M-x tmp-register RET` (or by key combination if you set that) in a buffer that is visiting a file, it will be saved to the register and you will be able to jump back to that buffer with `jump-to-register` (bound to `C-x r j` for me) and then typing `q` (or however you access registers in your setup). Note that if you call the function in a buffer that is not visiting a file (e.g., the `*Scratch*` buffer, it will not work.
1. "*I want to access any current file quickly. Therefore I want to build a function that put a file the register.*"

I hope you realize that Emacs-Lisp "registers" are not computer registers. There is nothing inherently super-quick about them. A Lisp register is essentially a pointer to an object in memory, like a variable.

Of course there is nothing wrong with using a register to save the content of a file or buffer. I just wanted to point out that using a register is not quicker than other means of doing the same thing.
2. As an alternative, consider using Emacs [**bookmarks**](http://www.gnu.org/software/emacs/manual/html_node/emacs/Bookmarks.html). They can be persistent or temporary; they point to file or buffer locations; and they are accessed quickly.

Of course, if a file has not yet been visited or the buffer does not yet exist, then there is the cost of visiting that data. But that is true however you proceed. Once a buffer exists that corresponds to the data you want, jumping to it using a bookmark is immediate.

It's the same as using a register, except that (1) a bookmark can have any name you like -- not just a character, and (2) a bookmark can be persistent.