Skip to content

Instantly share code, notes, and snippets.

@paxperscientiam
Last active July 8, 2016 12:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save paxperscientiam/394433dedb1a9de931700872c69de8c5 to your computer and use it in GitHub Desktop.
Save paxperscientiam/394433dedb1a9de931700872c69de8c5 to your computer and use it in GitHub Desktop.
php include show
;;; active experiment -- YOU USE THIS CODE AT YOUR OWN PERIL
;;; comments and criticisms welcome
;; dependencies: ShingoFukuyama/ov.el
;; credits: offby1 & ijp @ freenode/#emacs
;;
;;
;;; set variables
(setq captureFileRegExp "^<\\?php\s+include\s+[\"\']\\([\/a-z0-9]+\.[a-z]+\\)[\"\']\;\/\/ov\s+\\?>\n$")
;;
;;
;; r is for reveal! need to conditional. Like, if both open and close tags exist, then proceed
(define-key global-map (kbd "C-c C-r")
(defun get-include ()
(interactive)
(setq ov-php-include (ov-regexp captureFileRegExp))
(ov-read-only ov-php-include t t)
(ov-set ov-php-include 'after-string (concat "\n" (get-file-content)) 'face '(:foreground "red" :background "black"))))
;;
;;
;;; ofby1 was correct!
(defun get-file-content ()
(let ((p (get-file-path)))
(with-temp-buffer
(insert-file-contents p t)
(buffer-string))
))
;;
;;
;; This successfully gets file path, but needs to search entire line by default
(defun get-file-path ()
(re-search-forward captureFileRegExp (cdr (bounds-of-thing-at-point 'line))) (match-string 1))
(ov-clear)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; php below
<?php include '/tmp/env.output';//ov ?>
;; todo
;; understand elisp
;; doctrings
;; search should begin at beginning of line, not at point
;; search needs to be case insenstive
;; why can't i scroll long overlays??
;; error handling
;; make overlay instead of repeat. just a matter of using ov test functions
;; apply mode to overlay
;; when match fails, suggest fixes
;; finesse regex so to make file quote marks match
;; Local Variables:
;; firestarter: "gist -u 394433dedb1a9de931700872c69de8c5 %p"
;; End:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment