Fix some bugs in python linting on devserver
This commit is contained in:
parent
2d92526d24
commit
de8429de5d
5 changed files with 155 additions and 51 deletions
|
|
@ -124,6 +124,9 @@
|
|||
'tss ; Typescript, ala https://github.com/aki2o/emacs-tss
|
||||
'web-mode ; Mixed mode web editing
|
||||
'zencoding-mode ; http://www.emacswiki.org/emacs/ZenCoding
|
||||
|
||||
'tuareg ; ocaml
|
||||
'merlin ; ocaml completion stuff
|
||||
)
|
||||
"Libraries that should be installed by default.")
|
||||
|
||||
|
|
@ -606,7 +609,7 @@
|
|||
|
||||
(flycheck-define-checker python-fb-flake8
|
||||
"A Python syntax and style checker using FB's Flake8."
|
||||
:command ("flake8")
|
||||
:command ("flake8" source-original)
|
||||
:standard-input nil
|
||||
:error-filter (lambda (errors)
|
||||
(let ((errors (flycheck-sanitize-errors errors)))
|
||||
|
|
@ -614,11 +617,12 @@
|
|||
errors))
|
||||
:error-patterns
|
||||
((warning line-start
|
||||
"stdin:" line ":" (optional column ":") " "
|
||||
(file-name) ":" line ":" (optional column ":") " "
|
||||
(id (one-or-more (any alpha)) (one-or-more digit)) " "
|
||||
(message (one-or-more not-newline))
|
||||
line-end))
|
||||
:modes python-mode)
|
||||
(add-to-list 'flycheck-checkers 'python-fb-flake8)
|
||||
|
||||
(when is-fb-environment
|
||||
(add-hook 'python-mode-hook
|
||||
|
|
@ -843,5 +847,10 @@
|
|||
;;
|
||||
(global-set-key (kbd "C-/") 'comment-or-uncomment-region)
|
||||
|
||||
;; =================================================================
|
||||
;; OCAML stuff
|
||||
;; =================================================================
|
||||
(require 'opam-user-setup "~/.emacs.d/opam-user-setup.el")
|
||||
|
||||
(provide 'core)
|
||||
;;; core.el ends here
|
||||
|
|
|
|||
|
|
@ -33,11 +33,17 @@
|
|||
'(js2-strict-trailing-comma-warning nil)
|
||||
'(make-backup-files nil)
|
||||
'(mouse-buffer-menu-mode-mult 0)
|
||||
'(org-export-with-toc nil)
|
||||
'(org-hide-leading-stars t)
|
||||
'(org-odd-levels-only t)
|
||||
'(org-todo-keywords
|
||||
(quote
|
||||
((sequence "TODO" "|" "DONE" "ABANDONED" "DEFERRED"))))
|
||||
'(package-selected-packages
|
||||
(quote
|
||||
(dockerfile-mode js2-mode ## web-mode ahg zencoding-mode tss switch-window python-mode paredit monky magit lua-mode go-mode go-autocomplete flycheck exec-path-from-shell csharp-mode color-theme-solarized color-theme-monokai auto-complete-nxml)))
|
||||
(merlin tuareg markdown-mode thrift dockerfile-mode js2-mode ## web-mode ahg zencoding-mode tss switch-window python-mode paredit monky magit lua-mode go-mode go-autocomplete flycheck exec-path-from-shell csharp-mode color-theme-solarized color-theme-monokai auto-complete-nxml)))
|
||||
'(quip-api-key
|
||||
"UU9RQU1Ba0pjR08=|1517609175|FmwD/EJT5K//+ntQqzVopKmzq/juUmBQsS2hsNi8MeQ=")
|
||||
'(rmail-mail-new-frame t)
|
||||
'(safe-local-variable-values
|
||||
(quote
|
||||
|
|
|
|||
|
|
@ -1,33 +1,39 @@
|
|||
;;; ox-quip.el -- Publish from org-mode to Quip.
|
||||
|
||||
;;; Commentary:
|
||||
;; Publisher from org-mode to Quip. (Export as markdown, push as a new
|
||||
;; thread or amend to existing quip thread.)
|
||||
|
||||
;;; Code:
|
||||
(require 'cl-extra)
|
||||
(require 'ox-md)
|
||||
(require 'quip-api)
|
||||
(require 'quip)
|
||||
|
||||
|
||||
(defun org-quip-get-thread-identifier ()
|
||||
(defun org-quip--get-thread-identifier ()
|
||||
"Get the Quip thread identifier from the doc in the current buffer, if any."
|
||||
(org-entry-get nil "quip-id" t))
|
||||
|
||||
(defun org-quip-put-thread-identifier (identifier)
|
||||
(defun org-quip--put-thread-identifier (identifier)
|
||||
"Put the Quip thread identifier in IDENTIFIER into the doc."
|
||||
(save-excursion
|
||||
(while (org-up-heading-safe))
|
||||
(org-entry-put nil "quip-id" identifier)))
|
||||
|
||||
(defun org-quip-publish-quip (content)
|
||||
"Publish content as a new Quip document. Returns the ID of the new document."
|
||||
(defun org-quip--publish-quip (content)
|
||||
"Publish CONTENT as a new Quip document. Return the ID of the new document."
|
||||
(let ((response (quip-new-document content)))
|
||||
(cdr (assoc 'id (cdr (assoc 'thread response))))))
|
||||
|
||||
(defun org-quip-publish-to-quip ()
|
||||
"Publish the current buffer to Quip."
|
||||
(interactive)
|
||||
(let
|
||||
((quip-id (org-quip-get-thread-identifier))
|
||||
((quip-id (org-quip--get-thread-identifier))
|
||||
(content (org-export-as 'md)))
|
||||
(if quip-id
|
||||
(org-quip-update-quip quip-id content)
|
||||
(let ((new-quip-id (org-quip-publish-quip content)))
|
||||
(org-quip-put-thread-identifier new-quip-id)))))
|
||||
(let ((new-quip-id (org-quip--publish-quip content)))
|
||||
(org-quip--put-thread-identifier new-quip-id)))))
|
||||
|
||||
;;
|
||||
|
||||
|
|
@ -50,3 +56,4 @@
|
|||
|
||||
|
||||
(provide 'ox-quip)
|
||||
;;; ox-quip.el ends here
|
||||
|
|
|
|||
128
.emacs.d/quip.el
128
.emacs.d/quip.el
|
|
@ -1,19 +1,33 @@
|
|||
;; Quip API
|
||||
;;; quip.el --- Quip API client for emacs -*- lexical-binding: t; -*-
|
||||
;;; Commentary:
|
||||
|
||||
(require 'cl-extra)
|
||||
;;; Code:
|
||||
|
||||
(require 'cl-lib)
|
||||
(require 'json)
|
||||
(require 'url)
|
||||
|
||||
|
||||
;; Customization groups
|
||||
(defgroup quip-api nil
|
||||
"Customization options for using the Quip API")
|
||||
"Customization options for using the Quip API"
|
||||
:prefix "quip-"
|
||||
:group 'external
|
||||
:tag "Quip")
|
||||
|
||||
(defcustom quip-api-key nil
|
||||
"Your API key for Quip. Get it from https://fb.quip.com/api/personal-token"
|
||||
:type 'string)
|
||||
(defcustom quip-api-key ""
|
||||
"Your API key for Quip.
|
||||
|
||||
Get it from https://fb.quip.com/api/personal-token."
|
||||
:type 'string
|
||||
:group 'quip-api)
|
||||
|
||||
(defun quip-invoke-json (path method params)
|
||||
"Submit a request to the Quip API. Returns the parsed JSON from the response."
|
||||
"Make a request to the Quip API, and return the parsed JSON from the response.
|
||||
|
||||
A Quip API call involves issuing an HTTP request to path PATH,
|
||||
with method METHOD, and parameters PARAMS. This routine knows the
|
||||
base URL and adds the necessary headers."
|
||||
(if (not quip-api-key)
|
||||
(error "%s"
|
||||
"The custom variable quip-api-key is undefined. Use custom-set-variable to set it before using quip."))
|
||||
|
|
@ -32,14 +46,18 @@
|
|||
(json-read))))
|
||||
|
||||
(defun quip-new-document (content &optional format)
|
||||
"Create a new Quip document with the provided content. Returns the parsed JSON response."
|
||||
"Create a new Quip document with the provided CONTENT.
|
||||
|
||||
This function returns the parsed JSON response. The optional
|
||||
FORMAT argument is one of 'html' or 'markdown', and indicates
|
||||
that the content should be interpreted as such."
|
||||
(quip-invoke-json "threads/new-document"
|
||||
"POST"
|
||||
`((format . ,(or format "markdown"))
|
||||
(content . ,content))))
|
||||
|
||||
(defun quip-get-thread (id)
|
||||
"Get the Quip thread with the specified ID. Returns the parsed JSON response."
|
||||
"Get the Quip thread with the specified ID. Return the parsed JSON response."
|
||||
(quip-invoke-json (concat "threads/" id) "GET" nil))
|
||||
|
||||
(defconst quip-location-append 0)
|
||||
|
|
@ -50,7 +68,11 @@
|
|||
(defconst quip-location-delete-section 5)
|
||||
|
||||
(defun quip-thread-append (thread content &optional format)
|
||||
"Append the content to the specified thread."
|
||||
; checkdoc-order: nil
|
||||
"Append CONTENT to the specified THREAD.
|
||||
|
||||
The optional FORMAT argument is one of 'html' or 'markdown', and
|
||||
indicates how the content is to be interpreted."
|
||||
(quip-invoke-json "threads/edit-document"
|
||||
"POST"
|
||||
`((format . ,(or format "markdown"))
|
||||
|
|
@ -59,7 +81,11 @@
|
|||
(thread_id . ,thread))))
|
||||
|
||||
(defun quip-thread-prepend (thread content &optional format)
|
||||
"Prepend the content to the specified thread."
|
||||
; checkdoc-order: nil
|
||||
"Prepend CONTENT to the specified THREAD.
|
||||
|
||||
The optional FORMAT argument is one of 'html' or 'markdown', and
|
||||
indicates how the content is to be interpreted."
|
||||
(quip-invoke-json "threads/edit-document"
|
||||
"POST"
|
||||
`((format . ,(or format "markdown"))
|
||||
|
|
@ -68,27 +94,43 @@
|
|||
(thread_id . ,thread))))
|
||||
|
||||
(defun quip-thread-append-after (thread section content &optional format)
|
||||
"Append the content to the specified thread after the specified section."
|
||||
; checkdoc-order: nil
|
||||
"Append CONTENT to specified SECTION in the specified THREAD.
|
||||
|
||||
The content is appended after the specified section.
|
||||
|
||||
The optional FORMAT argument is one of 'html' or 'markdown', and
|
||||
indicates how the content is to be interpreted."
|
||||
(quip-invoke-json "threads/edit-document"
|
||||
"POST"
|
||||
`((format . ,(or format "markdown"))
|
||||
(content . ,content)
|
||||
(location . ,quip-location-append-section)
|
||||
(location . ,quip-location-after-section)
|
||||
(section_id . ,section)
|
||||
(thread_id . ,thread))))
|
||||
|
||||
(defun quip-thread-prepend-before (thread section content &optional format)
|
||||
"Prepend the content to the specified thread before the specified section."
|
||||
; checkdoc-order: nil
|
||||
"Prepend CONTENT to the specified SECTION of THREAD.
|
||||
|
||||
The content is added before the specified section.
|
||||
|
||||
The optional FORMAT argument is one of 'html' or 'markdown', and
|
||||
indicates how the content is to be interpreted."
|
||||
(quip-invoke-json "threads/edit-document"
|
||||
"POST"
|
||||
`((format . ,(or format "markdown"))
|
||||
(content . ,content)
|
||||
(location . ,quip-location-prepend-section)
|
||||
(location . ,quip-location-before-section)
|
||||
(section_id . ,section)
|
||||
(thread_id . ,thread))))
|
||||
|
||||
(defun quip-thread-replace-section (thread section content &optional format)
|
||||
"Replace the content of the specified section."
|
||||
; checkdoc-order: nil
|
||||
"Replace the specified SECTION of THREAD with the specified CONTENT.
|
||||
|
||||
The optional FORMAT argument is one of 'html' or 'markdown', and
|
||||
indicates how the content is to be interpreted."
|
||||
(quip-invoke-json "threads/edit-document"
|
||||
"POST"
|
||||
`((format . ,(or format "markdown"))
|
||||
|
|
@ -97,13 +139,12 @@
|
|||
(section_id . ,section)
|
||||
(thread_id . ,thread))))
|
||||
|
||||
(defun quip-thread-delete-section (thread section &optional format)
|
||||
"Delete the specified section."
|
||||
(defun quip-thread-delete-section (thread section)
|
||||
; checkdoc-order: nil
|
||||
"Delete the specified SECTION of THREAD."
|
||||
(quip-invoke-json "threads/edit-document"
|
||||
"POST"
|
||||
`((format . ,(or format "markdown"))
|
||||
(content . ,content)
|
||||
(location . ,quip-location-delete-section)
|
||||
`((location . ,quip-location-delete-section)
|
||||
(section_id . ,section)
|
||||
(thread_id . ,thread))))
|
||||
|
||||
|
|
@ -111,8 +152,8 @@
|
|||
;;; Content parsing functions
|
||||
|
||||
(defun quip-get-item-type (item)
|
||||
(let ((elem-type (car item))
|
||||
(attribs (cadr item)))
|
||||
"Classify the specified HTML ITEM."
|
||||
(let ((elem-type (car item)))
|
||||
(cond
|
||||
((eq elem-type 'p) 'paragraph)
|
||||
((eq elem-type 'h1) 'h1)
|
||||
|
|
@ -124,8 +165,7 @@
|
|||
((eq elem-type 'li) 'list-item)
|
||||
((eq elem-type 'span) 'span)
|
||||
((eq elem-type 'div)
|
||||
(letrec ((style (assoc-default 'data-section-style attribs))
|
||||
(inner (caddr item))
|
||||
(letrec ((inner (cl-caddr item))
|
||||
(inner-elem-type (car inner)))
|
||||
(cond
|
||||
((eq inner-elem-type 'ul) 'ul)
|
||||
|
|
@ -133,40 +173,49 @@
|
|||
(t 'unrecognized-inner))))
|
||||
(t 'unrecognized))))
|
||||
|
||||
(defun quip-get-item-id (type item)
|
||||
(defun quip-get-item-id (item type)
|
||||
"Extract the ID from the provided ITEM given its TYPE."
|
||||
(let ((attribs (cadr item)))
|
||||
(cond
|
||||
((or (eq type 'ul) ;; Nested IDs.
|
||||
(eq type 'ol))
|
||||
(letrec ((inner (caddr item))
|
||||
(letrec ((inner (cl-caddr item))
|
||||
(inner-attribs (cadr inner)))
|
||||
(assoc-default 'id inner-attribs)))
|
||||
(t (assoc-default 'id attribs)))))
|
||||
|
||||
(defun quip-get-item-content (type item)
|
||||
(defun quip-get-item-content (item type)
|
||||
"Extract the content from the provided ITEM given its TYPE."
|
||||
(cond
|
||||
((or (eq type 'ul) ;; Nested Content
|
||||
(eq type 'ol))
|
||||
(letrec ((inner (caddr item))
|
||||
(letrec ((inner (cl-caddr item))
|
||||
(inner-elems (cddr inner)))
|
||||
(mapcar #'quip-get-item-from-element inner-elems)))
|
||||
(t (caddr item))))
|
||||
(t (cl-caddr item))))
|
||||
|
||||
(cl-defstruct quip-item type id content)
|
||||
|
||||
(defun quip-get-item-from-element (element)
|
||||
"Construct a (type, id, content) list from the given ELEMENT."
|
||||
(letrec
|
||||
((item-type (quip-get-item-type element))
|
||||
(item-id (quip-get-item-id item-type element))
|
||||
(item-content (quip-get-item-content item-type element)))
|
||||
`(,item-type ,item-id ,item-content)))
|
||||
(item-id (quip-get-item-id element item-type))
|
||||
(item-content (quip-get-item-content element item-type)))
|
||||
(make-quip-item
|
||||
:type item-type
|
||||
:id item-id
|
||||
:content item-content)))
|
||||
|
||||
|
||||
(defun quip-parse-html-content (content)
|
||||
(defun quip-parse-html-content (html)
|
||||
"Parse the provided HTML into a list of (type, item, content) lists."
|
||||
(with-temp-buffer
|
||||
(insert content)
|
||||
(insert html)
|
||||
(letrec
|
||||
((html (libxml-parse-html-region (point-min) (point-max)))
|
||||
(raw-items (cddr (caddr html)))
|
||||
(html-items (remove-if #'stringp raw-items)))
|
||||
((parsed-html (libxml-parse-html-region (point-min) (point-max)))
|
||||
(raw-items (cddr (cl-caddr parsed-html)))
|
||||
(html-items (cl-remove-if #'stringp raw-items)))
|
||||
|
||||
(mapcar #'quip-get-item-from-element html-items)
|
||||
)))
|
||||
|
|
@ -175,4 +224,5 @@
|
|||
;; (quip-parse-html-content
|
||||
;; (assoc-default 'html (quip-get-thread "idflAWG6R6Uu"))))
|
||||
|
||||
(provide 'quip-api)
|
||||
(provide 'quip)
|
||||
;;; quip.el ends here
|
||||
|
|
|
|||
32
.vimrc
32
.vimrc
|
|
@ -91,3 +91,35 @@ if !exists(":DiffOrig")
|
|||
\ | wincmd p | diffthis
|
||||
endif
|
||||
|
||||
" ## added by OPAM user-setup for vim / base ## 93ee63e278bdfc07d1139a748ed3fff2 ## you can edit, but keep this line
|
||||
let s:opam_share_dir = system("opam config var share")
|
||||
let s:opam_share_dir = substitute(s:opam_share_dir, '[\r\n]*$', '', '')
|
||||
|
||||
let s:opam_configuration = {}
|
||||
|
||||
function! OpamConfOcpIndent()
|
||||
execute "set rtp^=" . s:opam_share_dir . "/ocp-indent/vim"
|
||||
endfunction
|
||||
let s:opam_configuration['ocp-indent'] = function('OpamConfOcpIndent')
|
||||
|
||||
function! OpamConfOcpIndex()
|
||||
execute "set rtp+=" . s:opam_share_dir . "/ocp-index/vim"
|
||||
endfunction
|
||||
let s:opam_configuration['ocp-index'] = function('OpamConfOcpIndex')
|
||||
|
||||
function! OpamConfMerlin()
|
||||
let l:dir = s:opam_share_dir . "/merlin/vim"
|
||||
execute "set rtp+=" . l:dir
|
||||
endfunction
|
||||
let s:opam_configuration['merlin'] = function('OpamConfMerlin')
|
||||
|
||||
let s:opam_packages = ["ocp-indent", "ocp-index", "merlin"]
|
||||
let s:opam_check_cmdline = ["opam list --installed --short --safe --color=never"] + s:opam_packages
|
||||
let s:opam_available_tools = split(system(join(s:opam_check_cmdline)))
|
||||
for tool in s:opam_packages
|
||||
" Respect package order (merlin should be after ocp-index)
|
||||
if count(s:opam_available_tools, tool) > 0
|
||||
call s:opam_configuration[tool]()
|
||||
endif
|
||||
endfor
|
||||
" ## end of OPAM user-setup addition for vim / base ## keep this line
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue