pkg update and first config fix

org-brain not working, add org-roam
This commit is contained in:
2022-12-19 23:02:34 +01:00
parent 02b3e07185
commit 82f05baffe
885 changed files with 356098 additions and 36993 deletions

View File

@@ -1,10 +1,11 @@
;;; php.el --- PHP support for friends -*- lexical-binding: t; -*-
;; Copyright (C) 2020 Friends of Emacs-PHP development
;; Copyright (C) 2022 Friends of Emacs-PHP development
;; Copyright (C) 1985, 1987, 1992-2022 Free Software Foundation, Inc.
;; Author: USAMI Kenta <tadsan@zonu.me>
;; Created: 5 Dec 2018
;; Version: 1.24.0
;; Version: 1.24.2
;; Keywords: languages, php
;; Homepage: https://github.com/emacs-php/php-mode
;; License: GPL-3.0-or-later
@@ -26,9 +27,16 @@
;; This file provides common variable and functions for PHP packages.
;; These functions are copied function from GNU Emacs.
;;
;; - c-end-of-token (cc-engine.el)
;;
;;; Code:
(eval-when-compile
(require 'cc-mode)
(require 'cl-lib))
(require 'cc-engine)
(require 'flymake)
(require 'php-project)
(require 'rx)
@@ -60,16 +68,16 @@ The URL to use open PHP manual and search word."
You can replace \"en\" with your ISO language code."
:group 'php
:tag "PHP Manual URL"
:type '(choice (const :tag "English" 'en)
(const :tag "Brazilian Portuguese" 'pt_BR)
(const :tag "Chinese (Simplified)" 'zh)
(const :tag "French" 'fr)
(const :tag "German" 'de)
(const :tag "Japanese" 'ja)
(const :tag "Romanian" 'ro)
(const :tag "Russian" 'ru)
(const :tag "Spanish" 'es)
(const :tag "Turkish" 'tr)
:type '(choice (const :tag "English" en)
(const :tag "Brazilian Portuguese" pt_BR)
(const :tag "Chinese (Simplified)" zh)
(const :tag "French" fr)
(const :tag "German" de)
(const :tag "Japanese" ja)
(const :tag "Romanian" ro)
(const :tag "Russian" ru)
(const :tag "Spanish" es)
(const :tag "Turkish" tr)
(string :tag "PHP manual URL")))
(defcustom php-search-url nil
@@ -203,15 +211,27 @@ a completion list."
These are different from \"constants\" in strict terms.
see https://www.php.net/manual/language.constants.predefined.php")
(defconst php-re-token-symbols
(eval-when-compile
(regexp-opt (list "&" "&=" "array(" "(array)" "&&" "||" "(bool)" "(boolean)" "break;" "?>" "%>"
"??" "??=" ".=" "--" "/=" "=>" "(real)" "(double)" "(float)" "::" "..."
"__halt_compiler()" "++" "(int)" "(integer)" "==" ">=" "===" "!=" "<>" "!=="
"<=" "-=" "%=" "*=" "\\" "(object)" "->" "?->" "<?php" "<?" "<?=" "|=" "+="
"**" "**=" "<<" "<<=" "<=>" ">>" ">>=" "<<<" "(string)" "^=" "yield from"
"[" "]" "(" ")" "{" "}" ";")
t)))
;;; Utillity for locate language construction
(defsubst php-in-string-p ()
"Return non-nil if inside a string.
it is the character that will terminate the string, or t if the string should be terminated by a generic string delimiter."
It is the character that will terminate the string, or t if the string should
be terminated by a generic string delimiter."
(nth 3 (syntax-ppss)))
(defsubst php-in-comment-p ()
"Return nil if outside a comment, t if inside a non-nestable comment, else an integer (the current comment nesting)."
"Return NIL if outside a comment, T if inside a non-nestable comment, else
an integer (the current comment nesting)."
(nth 4 (syntax-ppss)))
(defsubst php-in-string-or-comment-p ()
@@ -241,12 +261,12 @@ it is the character that will terminate the string, or t if the string should be
"Make a regular expression for methods with the given VISIBILITY.
VISIBILITY must be a string that names the visibility for a PHP
method, e.g. 'public'. The parameter VISIBILITY can itself also
method, e.g. \'public\'. The parameter VISIBILITY can itself also
be a regular expression.
The regular expression this function returns will check for other
keywords that can appear in method signatures, e.g. 'final' and
'static'. The regular expression will have one capture group
keywords that can appear in method signatures, e.g. \'final\' and
\'static\'. The regular expression will have one capture group
which will be the name of the method."
(when (stringp visibility)
(setq visibility (list visibility)))
@@ -273,8 +293,8 @@ which will be the name of the method."
'((* any) line-end))))))
(defun php-create-regexp-for-classlike (type)
"Accepts a `TYPE' of a 'classlike' object as a string, such as
'class' or 'interface', and returns a regexp as a string which
"Accepts a `TYPE' of a \'classlike\' object as a string, such as
\'class\' or \'interface\', and returns a regexp as a string which
can be used to match against definitions for that classlike."
(concat
;; First see if 'abstract' or 'final' appear, although really these
@@ -409,8 +429,8 @@ can be used to match against definitions for that classlike."
(defcustom php-imenu-generic-expression 'php-imenu-generic-expression-default
"Default Imenu generic expression for PHP Mode. See `imenu-generic-expression'."
:type '(choice (alist :key-type string :value-type list)
(const 'php-imenu-generic-expression-legacy)
(const 'php-imenu-generic-expression-simple)
(const php-imenu-generic-expression-legacy)
(const php-imenu-generic-expression-simple)
variable)
:group 'php)
@@ -422,6 +442,17 @@ can be used to match against definitions for that classlike."
(eval-when-compile
(php-create-regexp-for-classlike (regexp-opt '("class" "interface" "trait")))))
(defvar php--analysis-syntax-table
(eval-when-compile
(let ((table (make-syntax-table)))
(c-populate-syntax-table table)
(modify-syntax-entry ?_ "w" table)
(modify-syntax-entry ?` "\"" table)
(modify-syntax-entry ?\" "\"" table)
(modify-syntax-entry ?# "< b" table)
(modify-syntax-entry ?\n "> b" table)
table)))
(defun php-get-current-element (re-pattern)
"Return backward matched element by RE-PATTERN."
(save-excursion
@@ -429,27 +460,88 @@ can be used to match against definitions for that classlike."
(when (re-search-backward re-pattern nil t)
(match-string-no-properties 1)))))
(defun php-get-pattern ()
"Find the pattern we want to complete.
`find-tag-default' from GNU Emacs etags.el"
(eval-and-compile
(if (eval-when-compile (fboundp 'thing-at-point-bounds-of-string-at-point))
(defalias 'php--thing-at-point-bounds-of-string-at-point #'thing-at-point-bounds-of-string-at-point)
;; Copyright (C) 1991-1998, 2000-2022 Free Software Foundation, Inc.
;; Follows function is copied from Emacs 28's thingatpt.el.
;; https://github.com/emacs-mirror/emacs/commit/2abf143f8185fced544c4f8d144ea710142d7a59
(defun php--thing-at-point-bounds-of-string-at-point ()
"Return the bounds of the string at point.
Prefer the enclosing string with fallback on sexp at point.
\[Internal function used by `bounds-of-thing-at-point'.]"
(save-excursion
(let ((ppss (syntax-ppss)))
(if (nth 3 ppss)
;; Inside the string
(ignore-errors
(goto-char (nth 8 ppss))
(cons (point) (progn (forward-sexp) (point))))
;; At the beginning of the string
(if (eq (char-syntax (char-after)) ?\")
(let ((bound (bounds-of-thing-at-point 'sexp)))
(and bound
(<= (car bound) (point)) (< (point) (cdr bound))
bound))))))))
(if (eval-when-compile (fboundp 'c-end-of-token))
(defalias 'php--c-end-of-token #'c-end-of-token)
;; Copyright (C) 1985, 1987, 1992-2022 Free Software Foundation, Inc.
;; Follows function is copied from Emacs 27's cc-engine.el.
;; https://emba.gnu.org/emacs/emacs/-/commit/95fb826dc58965eac287c0826831352edf2e56f7
(defun php--c-end-of-token (&optional back-limit)
;; Move to the end of the token we're just before or in the middle of.
;; BACK-LIMIT may be used to bound the backward search; if given it's
;; assumed to be at the boundary between two tokens. Return non-nil if the
;; point is moved, nil otherwise.
;;
;; This function might do hidden buffer changes.
(let ((start (point)))
(cond ;; ((< (skip-syntax-backward "w_" (1- start)) 0)
;; (skip-syntax-forward "w_"))
((> (skip-syntax-forward "w_") 0))
((< (skip-syntax-backward ".()" back-limit) 0)
(while (< (point) start)
(if (looking-at c-nonsymbol-token-regexp)
(goto-char (match-end 0))
;; `c-nonsymbol-token-regexp' should always match since
;; we've skipped backward over punctuation or paren
;; syntax, but move forward in case it doesn't so that
;; we don't leave point earlier than we started with.
(forward-char))))
(t (if (looking-at c-nonsymbol-token-regexp)
(goto-char (match-end 0)))))
(> (point) start)))))
(defun php-leading-tokens (length)
"Return a list of leading LENGTH tokens from cursor point.
The token list is lined up in the opposite side of the visual arrangement.
The order is reversed by calling as follows:
\(nreverse \(php-leading-tokens 3\)\)"
(save-excursion
(save-match-data
(while (looking-at "\\sw\\|\\s_")
(forward-char 1))
(when (or (re-search-backward "\\sw\\|\\s_"
(save-excursion (beginning-of-line) (point))
t)
(re-search-forward "\\(\\sw\\|\\s_\\)+"
(save-excursion (end-of-line) (point))
t))
(goto-char (match-end 0))
(buffer-substring-no-properties
(point)
(progn
(forward-sexp -1)
(while (looking-at "\\s'")
(forward-char 1))
(point)))))))
(with-syntax-table php--analysis-syntax-table
(cl-loop
repeat length
do (progn
(forward-comment (- (point)))
(c-backward-token-2 1 nil))
collect
(cond
((when-let (bounds (php--thing-at-point-bounds-of-string-at-point))
(prog1 (buffer-substring-no-properties (car bounds) (cdr bounds))
(goto-char (car bounds)))))
((looking-at php-re-token-symbols)
(prog1 (match-string-no-properties 0)
(goto-char (match-beginning 0))))
(t
(buffer-substring-no-properties (point)
(save-excursion (php--c-end-of-token) (point))))))))))
(defun php-get-pattern ()
"Find the pattern we want to complete.
`find-tag-default' from GNU Emacs etags.el."
(car (php-leading-tokens 1)))
;;; Provide support for Flymake so that users can see warnings and
;;; errors in real-time as they write code.
@@ -458,11 +550,9 @@ can be used to match against definitions for that classlike."
This is an alternative function of `flymake-php-init'.
Look at the `php-executable' variable instead of the constant \"php\" command."
(let* ((init (funcall (eval-when-compile
(if (fboundp 'flymake-proc-php-init)
'flymake-proc-php-init
'flymake-php-init)))))
(list php-executable (cdr init))))
(let ((init (with-no-warnings (flymake-php-init))))
(setf (car init) php-executable)
init))
(defconst php-re-detect-html-tag-aggressive
(eval-when-compile
@@ -490,8 +580,8 @@ Look at the `php-executable' variable instead of the constant \"php\" command."
"Regexp pattern variable-name of HTML detection."
:group 'php
:tag "PHP Re Detect HTML Tag"
:type '(choice (const :tag "Default pattern" 'php-re-detect-html-tag-default)
(const :tag "Aggressive pattern" 'php-re-detect-html-tag-aggressive)
:type '(choice (const :tag "Default pattern" php-re-detect-html-tag-default)
(const :tag "Aggressive pattern" php-re-detect-html-tag-aggressive)
(variable :tag "Variable name of RegExp pattern")))
(defsubst php-re-detect-html-tag ()
@@ -583,7 +673,8 @@ When `DOCUMENT-ROOT' is NIL, the document root is obtained from `ROUTER-OR-DIR'.
(read-number "Port: " php-default-builtin-web-server-port)
(if (file-directory-p d-o-r)
nil
(let ((root-input (read-file-name "Document root: " (directory-file-name d-o-r))))
(let ((root-input (expand-file-name
(read-file-name "Document root: " (directory-file-name d-o-r)))))
(file-name-directory
(if (file-directory-p root-input)
root-input
@@ -600,8 +691,8 @@ When `DOCUMENT-ROOT' is NIL, the document root is obtained from `ROUTER-OR-DIR'.
port
short-dirname
(if document-root short-filename "")))
(args (cl-remove-if
#'null
(args (delq
nil
(list "-S"
(format "%s:%d" hostname port)
"-t"