comparison lisp/bookmark.el @ 92661:c8674d7009d4

* bookmark.el (bookmark-prop-get, bookmark-prop-set): New funs. (bookmark-get-annotation, bookmark-set-annotation) (bookmark-get-filename, bookmark-set-filename, bookmark-get-position) (bookmark-set-position, bookmark-get-front-context-string) (bookmark-set-front-context-string, bookmark-get-rear-context-string) (bookmark-set-rear-context-string, bookmark-get-handler): Use them. * info.el (Info-bookmark-make-record): Don't bother recording point. (bookmark-get-filename, bookmark-get-front-context-string) (bookmark-get-rear-context-string, bookmark-get-position): Don't declare. (bookmark-get-info-node): Remove. (bookmark-prop-get): Declare. (Info-bookmark-jump): Use it.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Sat, 08 Mar 2008 22:07:23 +0000
parents f91d9f543b0a
children ac3c6c3e119c
comparison
equal deleted inserted replaced
92660:e64439fb46dc 92661:c8674d7009d4
346 "Set BOOKMARK's name to NEWNAME." 346 "Set BOOKMARK's name to NEWNAME."
347 (setcar 347 (setcar
348 (if (stringp bookmark) (bookmark-get-bookmark bookmark) bookmark) 348 (if (stringp bookmark) (bookmark-get-bookmark bookmark) bookmark)
349 newname)) 349 newname))
350 350
351 (defun bookmark-prop-get (bookmark prop)
352 "Return the property PROP of BOOKMARK, or nil if none."
353 (cdr (assq prop (bookmark-get-bookmark-record bookmark))))
354
355 (defun bookmark-prop-set (bookmark prop val)
356 "Set the property PROP of BOOKMARK to VAL."
357 (let ((cell (assq prop (bookmark-get-bookmark-record bookmark))))
358 (if cell
359 (setcdr cell val)
360 (nconc (bookmark-get-bookmark-record bookmark)
361 (list (cons prop val))))))
351 362
352 (defun bookmark-get-annotation (bookmark) 363 (defun bookmark-get-annotation (bookmark)
353 "Return the annotation of BOOKMARK, or nil if none." 364 "Return the annotation of BOOKMARK, or nil if none."
354 (cdr (assq 'annotation (bookmark-get-bookmark-record bookmark)))) 365 (bookmark-prop-get bookmark 'annotation))
355
356 366
357 (defun bookmark-set-annotation (bookmark ann) 367 (defun bookmark-set-annotation (bookmark ann)
358 "Set the annotation of BOOKMARK to ANN." 368 "Set the annotation of BOOKMARK to ANN."
359 (let ((cell (assq 'annotation (bookmark-get-bookmark-record bookmark)))) 369 (bookmark-prop-set bookmark 'annotation ann))
360 (if cell
361 (setcdr cell ann)
362 (nconc (bookmark-get-bookmark-record bookmark)
363 (list (cons 'annotation ann))))))
364 370
365 371
366 (defun bookmark-get-filename (bookmark) 372 (defun bookmark-get-filename (bookmark)
367 "Return the full filename of BOOKMARK." 373 "Return the full filename of BOOKMARK."
368 (cdr (assq 'filename (bookmark-get-bookmark-record bookmark)))) 374 (bookmark-prop-get bookmark 'filename))
369 375
370 376
371 (defun bookmark-set-filename (bookmark filename) 377 (defun bookmark-set-filename (bookmark filename)
372 "Set the full filename of BOOKMARK to FILENAME." 378 "Set the full filename of BOOKMARK to FILENAME."
373 (let ((cell (assq 'filename (bookmark-get-bookmark-record bookmark)))) 379 (bookmark-prop-set bookmark 'filename filename)
374 (if cell 380 (setq bookmark-alist-modification-count
375 (setcdr cell filename) 381 (1+ bookmark-alist-modification-count))
376 (nconc (bookmark-get-bookmark-record bookmark) 382 (if (bookmark-time-to-save-p)
377 (list (cons 'filename filename)))) 383 (bookmark-save)))
378 (setq bookmark-alist-modification-count
379 (1+ bookmark-alist-modification-count))
380 (if (bookmark-time-to-save-p)
381 (bookmark-save))))
382 384
383 385
384 (defun bookmark-get-position (bookmark) 386 (defun bookmark-get-position (bookmark)
385 "Return the position \(i.e.: point\) of BOOKMARK." 387 "Return the position \(i.e.: point\) of BOOKMARK."
386 (cdr (assq 'position (bookmark-get-bookmark-record bookmark)))) 388 (bookmark-prop-get bookmark 'position))
387 389
388 390
389 (defun bookmark-set-position (bookmark position) 391 (defun bookmark-set-position (bookmark position)
390 "Set the position \(i.e.: point\) of BOOKMARK to POSITION." 392 "Set the position \(i.e.: point\) of BOOKMARK to POSITION."
391 (let ((cell (assq 'position (bookmark-get-bookmark-record bookmark)))) 393 (bookmark-prop-set bookmark 'position position))
392 (if cell
393 (setcdr cell position)
394 (nconc (bookmark-get-bookmark-record bookmark)
395 (list (cons 'position position))))))
396 394
397 395
398 (defun bookmark-get-front-context-string (bookmark) 396 (defun bookmark-get-front-context-string (bookmark)
399 "Return the front-context-string of BOOKMARK." 397 "Return the front-context-string of BOOKMARK."
400 (cdr (assq 'front-context-string (bookmark-get-bookmark-record bookmark)))) 398 (bookmark-prop-get bookmark 'front-context-string))
401 399
402 400
403 (defun bookmark-set-front-context-string (bookmark string) 401 (defun bookmark-set-front-context-string (bookmark string)
404 "Set the front-context-string of BOOKMARK to STRING." 402 "Set the front-context-string of BOOKMARK to STRING."
405 (let ((cell (assq 'front-context-string 403 (bookmark-prop-set bookmark 'front-context-string string))
406 (bookmark-get-bookmark-record bookmark))))
407 (if cell
408 (setcdr cell string)
409 (nconc (bookmark-get-bookmark-record bookmark)
410 (list (cons 'front-context-string string))))))
411 404
412 405
413 (defun bookmark-get-rear-context-string (bookmark) 406 (defun bookmark-get-rear-context-string (bookmark)
414 "Return the rear-context-string of BOOKMARK." 407 "Return the rear-context-string of BOOKMARK."
415 (cdr (assq 'rear-context-string (bookmark-get-bookmark-record bookmark)))) 408 (bookmark-prop-get bookmark 'rear-context-string))
416 409
417 410
418 (defun bookmark-set-rear-context-string (bookmark string) 411 (defun bookmark-set-rear-context-string (bookmark string)
419 "Set the rear-context-string of BOOKMARK to STRING." 412 "Set the rear-context-string of BOOKMARK to STRING."
420 (let ((cell (assq 'rear-context-string 413 (bookmark-prop-set bookmark 'rear-context-string string))
421 (bookmark-get-bookmark-record bookmark))))
422 (if cell
423 (setcdr cell string)
424 (nconc (bookmark-get-bookmark-record bookmark)
425 (list (cons 'rear-context-string string))))))
426 414
427 415
428 (defun bookmark-get-handler (bookmark) 416 (defun bookmark-get-handler (bookmark)
429 (cdr (assq 'handler (bookmark-get-bookmark-record bookmark)))) 417 (bookmark-prop-get bookmark 'handler))
430 418
431 (defvar bookmark-history nil 419 (defvar bookmark-history nil
432 "The history list for bookmark functions.") 420 "The history list for bookmark functions.")
433 421
434 422