Skip to content

Instantly share code, notes, and snippets.

@yappo
Forked from imakado/gist:176075
Created August 27, 2009 05:51
Show Gist options
  • Save yappo/176111 to your computer and use it in GitHub Desktop.
Save yappo/176111 to your computer and use it in GitHub Desktop.
(defun perl-insert-package ()
(interactive)
(require 'perl-completion)
(cond
((null buffer-file-truename) (error "no buffer-file-truename"))
(t
(let* ((s (replace-regexp-in-string
(rx-to-string `(and bol ,(plcmp--get-lib-path) (? "/")))
""
(expand-file-name buffer-file-truename)))
(s (file-name-sans-extension (replace-regexp-in-string (rx "/") "::" (replace-regexp-in-string "^.+/lib/" "" s)))))
(insert "package " s ";")))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment