Skip to content

Instantly share code, notes, and snippets.

@ceving
Created January 21, 2016 13:59
Show Gist options
  • Save ceving/011fa52a220612bc0466 to your computer and use it in GitHub Desktop.
Save ceving/011fa52a220612bc0466 to your computer and use it in GitHub Desktop.
Define all parent directories of a path in a prototype file for Sun's pkgmk tool creating Solaris packages.
(defun sunpkg-mkdir ()
"Define all parent directories of a path in a prototype file
for Sun's pkgmk tool creating Solaris packages. When the cursor
is in a line containing the following crontab definition
e cron var/spool/cron/crontabs/root=src/crontab ? ? ?
the function will insert the following directories in front of if
d cron var ? ? ?
d cron var/spool ? ? ?
d cron var/spool/cron ? ? ?
d cron var/spool/cron/crontabs ? ? ?
"
(interactive)
(save-excursion
(beginning-of-line)
(if (looking-at "^[de]\\s-+\\(\\w+\\)\\s-+\\([^ =]+\\)")
(let ((path nil)
(class (match-string 1)))
(dolist (element (butlast (split-string (match-string 2) "/")))
(setq path (if path
(concat path "/" element)
element))
(insert "d " class " " path " ? ? ?")
(newline))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment