You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: get_pencil_curve.m
    path of file: ./repos/gptoolbox/mesh
    
    the code of the file until where you have to start completion: function [P,p] = get_pencil_curve(f,varargin)
  % GET_PENCIL_CURVE Get a curve (sequence of points) from the user by dragging
  % on the current plot window
  %
    
function append_current_point()
    % get current mouse position, and remember old one
    cp = get(gca,'currentpoint');
    P = [P;cp(1,:)];
    if isempty(p)
      hold on;
      p = plot(P(:,1),P(:,2),varargin{:});
      hold off;
    else
      set(p,'Xdata',P(:,1),'Ydata',P(:,2));
    end