69
69
70
70
(require 'font-lock )
71
71
(require 'custom )
72
- (require 'etags )
73
72
(require 'speedbar )
74
73
(require 'imenu )
75
74
(require 'package )
@@ -1267,10 +1266,7 @@ After setting the stylevars run hooks according to STYLENAME
1267
1266
#'semantic-create-imenu-index )
1268
1267
" Imenu index function for PHP." )
1269
1268
1270
-
1271
- ; ; Define function name completion function
1272
- (defvar php-completion-table nil
1273
- " Obarray of tag names defined in current tags table and functions known to PHP." )
1269
+ (autoload 'php-local-manual-complete-function " php-local-manual" )
1274
1270
1275
1271
(defun php-complete-function ()
1276
1272
" Perform function completion on the text around point.
@@ -1279,102 +1275,7 @@ and the standard php functions.
1279
1275
The string to complete is chosen in the same way as the default
1280
1276
for \\ [find-tag] (which see)."
1281
1277
(interactive )
1282
- (let ((pattern (php-get-pattern))
1283
- beg
1284
- completion
1285
- (php-functions (php-completion-table)))
1286
- (if (not pattern) (message " Nothing to complete " )
1287
- (if (not (search-backward pattern nil t ))
1288
- (message " Can't complete here " )
1289
- (setq beg (point ))
1290
- (forward-char (length pattern))
1291
- (setq completion (try-completion pattern php-functions nil ))
1292
- (cond ((eq completion t ))
1293
- ((null completion)
1294
- (message " Can't find completion for \" %s \" " pattern)
1295
- (ding ))
1296
- ((not (string= pattern completion))
1297
- (delete-region beg (point ))
1298
- (insert completion))
1299
- (t
1300
- (let ((selected (completing-read
1301
- " Select completion: "
1302
- (all-completions pattern php-functions)
1303
- nil t pattern)))
1304
- (delete-region beg (point ))
1305
- (insert selected))))))))
1306
-
1307
- (defun php-completion-table ()
1308
- " Build variable `php-completion-table' on demand.
1309
- The table includes the PHP functions and the tags from the
1310
- current `tags-file-name' ."
1311
- (or (and tags-file-name
1312
- (save-excursion (tags-verify-table tags-file-name))
1313
- php-completion-table)
1314
- (let ((tags-table
1315
- (when tags-file-name
1316
- (with-current-buffer (get-file-buffer tags-file-name)
1317
- (etags-tags-completion-table ))))
1318
- (php-table
1319
- (cond ((and (not (string= " " php-completion-file))
1320
- (file-readable-p php-completion-file))
1321
- (php-build-table-from-file php-completion-file))
1322
- ((and (not (string= " " php-manual-path))
1323
- (file-directory-p php-manual-path))
1324
- (php-build-table-from-path php-manual-path))
1325
- (t nil ))))
1326
- (unless (or php-table tags-table)
1327
- (error
1328
- (concat " No TAGS file active nor are "
1329
- " `php-completion-file' or `php-manual-path' set" )))
1330
- (when tags-table
1331
- ; ; Combine the tables.
1332
- (if (obarrayp tags-table)
1333
- (mapatoms (lambda (sym ) (intern (symbol-name sym) php-table))
1334
- tags-table)
1335
- (setq php-table (append tags-table php-table))))
1336
- (setq php-completion-table php-table))))
1337
-
1338
- (defun php-build-table-from-file (filename )
1339
- (let ((table (make-vector 1022 0 ))
1340
- (buf (find-file-noselect filename)))
1341
- (with-current-buffer buf
1342
- (goto-char (point-min ))
1343
- (while (re-search-forward
1344
- " ^\\ ([-a-zA-Z0-9_.]+\\ )\n "
1345
- nil t )
1346
- (intern (buffer-substring (match-beginning 1 ) (match-end 1 ))
1347
- table)))
1348
- (kill-buffer buf)
1349
- table))
1350
-
1351
- (defun php-build-table-from-path (path )
1352
- " Return list of PHP function name from `PATH' directory."
1353
- (cl-loop for file in (directory-files path nil " ^function\\ ..+\\ .html$" )
1354
- if (string-match " \\ .\\ ([-a-zA-Z_0-9]+\\ )\\ .html$" file)
1355
- collect (replace-regexp-in-string
1356
- " -" " _" (substring file (match-beginning 1 ) (match-end 1 )) t )))
1357
-
1358
- ; ; Find the pattern we want to complete
1359
- ; ; find-tag-default from GNU Emacs etags.el
1360
- (defun php-get-pattern ()
1361
- (save-excursion
1362
- (while (looking-at " \\ sw\\ |\\ s_" )
1363
- (forward-char 1 ))
1364
- (if (or (re-search-backward " \\ sw\\ |\\ s_"
1365
- (save-excursion (beginning-of-line ) (point ))
1366
- t )
1367
- (re-search-forward " \\ (\\ sw\\ |\\ s_\\ )+"
1368
- (save-excursion (end-of-line ) (point ))
1369
- t ))
1370
- (progn (goto-char (match-end 0 ))
1371
- (buffer-substring-no-properties
1372
- (point )
1373
- (progn (forward-sexp -1 )
1374
- (while (looking-at " \\ s'" )
1375
- (forward-char 1 ))
1376
- (point ))))
1377
- nil )))
1278
+ (php-local-manual-complete-function))
1378
1279
1379
1280
(defun php-show-arglist ()
1380
1281
" Show function arguments at cursor position."
0 commit comments